mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-12 09:09:47 +12:00
[CFG] Implement GetRegionCanadaUSA
This commit is contained in:
parent
c24c4a9d83
commit
2c7cbadc14
3 changed files with 153 additions and 3 deletions
|
@ -3,16 +3,19 @@
|
||||||
#include "helpers.hpp"
|
#include "helpers.hpp"
|
||||||
#include "logger.hpp"
|
#include "logger.hpp"
|
||||||
#include "memory.hpp"
|
#include "memory.hpp"
|
||||||
|
#include "region_codes.hpp"
|
||||||
|
|
||||||
class CFGService {
|
class CFGService {
|
||||||
Handle handle = KernelHandles::CFG;
|
Handle handle = KernelHandles::CFG;
|
||||||
Memory& mem;
|
Memory& mem;
|
||||||
|
CountryCodes country = CountryCodes::US; // Default to USA
|
||||||
MAKE_LOG_FUNCTION(log, cfgLogger)
|
MAKE_LOG_FUNCTION(log, cfgLogger)
|
||||||
|
|
||||||
void writeStringU16(u32 pointer, const std::u16string& string);
|
void writeStringU16(u32 pointer, const std::u16string& string);
|
||||||
|
|
||||||
// Service functions
|
// Service functions
|
||||||
void getConfigInfoBlk2(u32 messagePointer);
|
void getConfigInfoBlk2(u32 messagePointer);
|
||||||
|
void getRegionCanadaUSA(u32 messagePointer);
|
||||||
void genUniqueConsoleHash(u32 messagePointer);
|
void genUniqueConsoleHash(u32 messagePointer);
|
||||||
void secureInfoGetRegion(u32 messagePointer);
|
void secureInfoGetRegion(u32 messagePointer);
|
||||||
|
|
||||||
|
|
|
@ -39,4 +39,140 @@ enum class LanguageCodes : u32 {
|
||||||
Portuguese = PT,
|
Portuguese = PT,
|
||||||
Russian = RU,
|
Russian = RU,
|
||||||
Taiwanese = TW
|
Taiwanese = TW
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class CountryCodes : u32 {
|
||||||
|
JP = 1,
|
||||||
|
AI = 8,
|
||||||
|
AG = 9,
|
||||||
|
AR = 10,
|
||||||
|
AW = 11,
|
||||||
|
BS = 12,
|
||||||
|
BB = 13,
|
||||||
|
BZ = 14,
|
||||||
|
BO = 15,
|
||||||
|
BR = 16,
|
||||||
|
VG = 17,
|
||||||
|
CA = 18,
|
||||||
|
KY = 19,
|
||||||
|
CL = 20,
|
||||||
|
CO = 21,
|
||||||
|
CR = 22,
|
||||||
|
DM = 23,
|
||||||
|
DO = 24,
|
||||||
|
EC = 25,
|
||||||
|
SV = 26,
|
||||||
|
GF = 27,
|
||||||
|
GD = 28,
|
||||||
|
GP = 29,
|
||||||
|
GT = 30,
|
||||||
|
GY = 31,
|
||||||
|
HT = 32,
|
||||||
|
HN = 33,
|
||||||
|
JM = 34,
|
||||||
|
MQ = 35,
|
||||||
|
MX = 36,
|
||||||
|
MS = 37,
|
||||||
|
AN = 38,
|
||||||
|
NI = 39,
|
||||||
|
PA = 40,
|
||||||
|
PY = 41,
|
||||||
|
PE = 42,
|
||||||
|
KN = 43,
|
||||||
|
LC = 44,
|
||||||
|
VC = 45,
|
||||||
|
SR = 46,
|
||||||
|
TT = 47,
|
||||||
|
TC = 48,
|
||||||
|
US = 49,
|
||||||
|
UY = 50,
|
||||||
|
VI = 51,
|
||||||
|
VE = 52,
|
||||||
|
AL = 64,
|
||||||
|
AU = 65,
|
||||||
|
AT = 66,
|
||||||
|
BE = 67,
|
||||||
|
BA = 68,
|
||||||
|
BW = 69,
|
||||||
|
BG = 70,
|
||||||
|
HR = 71,
|
||||||
|
CY = 72,
|
||||||
|
CZ = 73,
|
||||||
|
DK = 74,
|
||||||
|
EE = 75,
|
||||||
|
FI = 76,
|
||||||
|
FR = 77,
|
||||||
|
DE = 78,
|
||||||
|
GR = 79,
|
||||||
|
HU = 80,
|
||||||
|
IS = 81,
|
||||||
|
IE = 82,
|
||||||
|
IT = 83,
|
||||||
|
LV = 84,
|
||||||
|
LS = 85,
|
||||||
|
LI = 86,
|
||||||
|
LT = 87,
|
||||||
|
LU = 88,
|
||||||
|
MK = 89,
|
||||||
|
MT = 90,
|
||||||
|
ME = 91,
|
||||||
|
MZ = 92,
|
||||||
|
NA = 93,
|
||||||
|
NL = 94,
|
||||||
|
NZ = 95,
|
||||||
|
NO = 96,
|
||||||
|
PL = 97,
|
||||||
|
PT = 98,
|
||||||
|
RO = 99,
|
||||||
|
RU = 100,
|
||||||
|
RS = 101,
|
||||||
|
SK = 102,
|
||||||
|
SI = 103,
|
||||||
|
ZA = 104,
|
||||||
|
ES = 105,
|
||||||
|
SZ = 106,
|
||||||
|
SE = 107,
|
||||||
|
CH = 108,
|
||||||
|
TR = 109,
|
||||||
|
GB = 110,
|
||||||
|
ZM = 111,
|
||||||
|
ZW = 112,
|
||||||
|
AZ = 113,
|
||||||
|
MR = 114,
|
||||||
|
ML = 115,
|
||||||
|
NE = 116,
|
||||||
|
TD = 117,
|
||||||
|
SD = 118,
|
||||||
|
ER = 119,
|
||||||
|
DJ = 120,
|
||||||
|
SO = 121,
|
||||||
|
AD = 122,
|
||||||
|
GI = 123,
|
||||||
|
GG = 124,
|
||||||
|
IM = 125,
|
||||||
|
JE = 126,
|
||||||
|
MC = 127,
|
||||||
|
TW = 128,
|
||||||
|
KR = 136,
|
||||||
|
HK = 144,
|
||||||
|
MO = 145,
|
||||||
|
ID = 152,
|
||||||
|
SG = 153,
|
||||||
|
TH = 154,
|
||||||
|
PH = 155,
|
||||||
|
MY = 156,
|
||||||
|
CN = 160,
|
||||||
|
AE = 168,
|
||||||
|
IND = 169, // We can't use the 2-letter country code for India because the Windows SDK does #define IN...
|
||||||
|
EG = 170,
|
||||||
|
OM = 171,
|
||||||
|
QA = 172,
|
||||||
|
KW = 173,
|
||||||
|
SA = 174,
|
||||||
|
SY = 175,
|
||||||
|
BH = 176,
|
||||||
|
JO = 177,
|
||||||
|
SM = 184,
|
||||||
|
VA = 185,
|
||||||
|
BM = 186,
|
||||||
};
|
};
|
|
@ -1,12 +1,12 @@
|
||||||
#include "services/cfg.hpp"
|
#include "services/cfg.hpp"
|
||||||
#include "services/dsp.hpp"
|
#include "services/dsp.hpp"
|
||||||
#include "services/region_codes.hpp"
|
|
||||||
|
|
||||||
namespace CFGCommands {
|
namespace CFGCommands {
|
||||||
enum : u32 {
|
enum : u32 {
|
||||||
GetConfigInfoBlk2 = 0x00010082,
|
GetConfigInfoBlk2 = 0x00010082,
|
||||||
SecureInfoGetRegion = 0x00020000,
|
SecureInfoGetRegion = 0x00020000,
|
||||||
GenHashConsoleUnique = 0x00030040
|
GenHashConsoleUnique = 0x00030040,
|
||||||
|
GetRegionCanadaUSA = 0x00040000
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ void CFGService::handleSyncRequest(u32 messagePointer) {
|
||||||
const u32 command = mem.read32(messagePointer);
|
const u32 command = mem.read32(messagePointer);
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case CFGCommands::GetConfigInfoBlk2: getConfigInfoBlk2(messagePointer); break;
|
case CFGCommands::GetConfigInfoBlk2: getConfigInfoBlk2(messagePointer); break;
|
||||||
|
case CFGCommands::GetRegionCanadaUSA: getRegionCanadaUSA(messagePointer); break;
|
||||||
case CFGCommands::GenHashConsoleUnique: genUniqueConsoleHash(messagePointer); break;
|
case CFGCommands::GenHashConsoleUnique: genUniqueConsoleHash(messagePointer); break;
|
||||||
case CFGCommands::SecureInfoGetRegion: secureInfoGetRegion(messagePointer); break;
|
case CFGCommands::SecureInfoGetRegion: secureInfoGetRegion(messagePointer); break;
|
||||||
default: Helpers::panic("CFG service requested. Command: %08X\n", command);
|
default: Helpers::panic("CFG service requested. Command: %08X\n", command);
|
||||||
|
@ -53,7 +54,7 @@ void CFGService::getConfigInfoBlk2(u32 messagePointer) {
|
||||||
mem.write8(output, 0); // Unknown
|
mem.write8(output, 0); // Unknown
|
||||||
mem.write8(output + 1, 0); // Unknown
|
mem.write8(output + 1, 0); // Unknown
|
||||||
mem.write8(output + 2, 2); // Province (Temporarily stubbed to Washington DC like Citra)
|
mem.write8(output + 2, 2); // Province (Temporarily stubbed to Washington DC like Citra)
|
||||||
mem.write8(output + 3, 49); // Country code (Temporarily stubbed to USA like Citra)
|
mem.write8(output + 3, static_cast<u8>(country)); // Country code
|
||||||
} else if (size == 0x20 && blockID == 0x50005) {
|
} else if (size == 0x20 && blockID == 0x50005) {
|
||||||
printf("[Unimplemented] Read stereo display settings from NAND\n");
|
printf("[Unimplemented] Read stereo display settings from NAND\n");
|
||||||
} else if (size == 0x1C && blockID == 0xA0000) { // Username
|
} else if (size == 0x1C && blockID == 0xA0000) { // Username
|
||||||
|
@ -112,4 +113,14 @@ void CFGService::genUniqueConsoleHash(u32 messagePointer) {
|
||||||
// Let's stub it for now
|
// Let's stub it for now
|
||||||
mem.write32(messagePointer + 8, 0x33646D6F ^ salt); // Lower word of hash
|
mem.write32(messagePointer + 8, 0x33646D6F ^ salt); // Lower word of hash
|
||||||
mem.write32(messagePointer + 12, 0xA3534841 ^ salt); // Upper word of hash
|
mem.write32(messagePointer + 12, 0xA3534841 ^ salt); // Upper word of hash
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns 1 if the console region is either Canada or USA, otherwise returns 0
|
||||||
|
// Used for market restriction-related stuff
|
||||||
|
void CFGService::getRegionCanadaUSA(u32 messagePointer) {
|
||||||
|
log("CFG::GetRegionCanadaUSA\n");
|
||||||
|
const u8 ret = (country == CountryCodes::US || country == CountryCodes::CA) ? 1 : 0;
|
||||||
|
|
||||||
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
|
mem.write8(messagePointer + 8, ret);
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue