From 7c2dd34eba0c98ac5dd03d518a57377d84003417 Mon Sep 17 00:00:00 2001 From: wheremyfoodat Date: Thu, 26 Jan 2023 02:20:54 +0200 Subject: [PATCH] [CFG] Stub GenUniqueConsoleHash --- include/services/cfg.hpp | 1 + src/core/services/cfg.cpp | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/services/cfg.hpp b/include/services/cfg.hpp index 64667ef8..a00e9afb 100644 --- a/include/services/cfg.hpp +++ b/include/services/cfg.hpp @@ -13,6 +13,7 @@ class CFGService { // Service functions void getConfigInfoBlk2(u32 messagePointer); + void genUniqueConsoleHash(u32 messagePointer); void secureInfoGetRegion(u32 messagePointer); public: diff --git a/src/core/services/cfg.cpp b/src/core/services/cfg.cpp index 66192485..62af8627 100644 --- a/src/core/services/cfg.cpp +++ b/src/core/services/cfg.cpp @@ -5,7 +5,8 @@ namespace CFGCommands { enum : u32 { GetConfigInfoBlk2 = 0x00010082, - SecureInfoGetRegion = 0x00020000 + SecureInfoGetRegion = 0x00020000, + GenHashConsoleUnique = 0x00030040 }; } @@ -21,6 +22,7 @@ void CFGService::handleSyncRequest(u32 messagePointer) { const u32 command = mem.read32(messagePointer); switch (command) { case CFGCommands::GetConfigInfoBlk2: getConfigInfoBlk2(messagePointer); break; + case CFGCommands::GenHashConsoleUnique: genUniqueConsoleHash(messagePointer); break; case CFGCommands::SecureInfoGetRegion: secureInfoGetRegion(messagePointer); break; default: Helpers::panic("CFG service requested. Command: %08X\n", command); } @@ -96,4 +98,15 @@ void CFGService::secureInfoGetRegion(u32 messagePointer) { mem.write32(messagePointer + 4, Result::Success); mem.write32(messagePointer + 8, static_cast(Regions::USA)); // TODO: Detect the game region and report it +} + +void CFGService::genUniqueConsoleHash(u32 messagePointer) { + log("CFG::GenUniqueConsoleHash (semi-stubbed)"); + const u32 salt = mem.read32(messagePointer + 4) & 0x000FFFFF; + + mem.write32(messagePointer + 4, Result::Success); + // We need to implement hash generation & the SHA-256 digest properly later on. We have cryptopp so the hashing isn't too hard to do + // Let's stub it for now + mem.write32(messagePointer + 8, 0x33646D6F ^ salt); // Lower word of hash + mem.write32(messagePointer + 12, 0xA3534841 ^ salt); // Upper word of hash } \ No newline at end of file