mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-23 18:19:21 +01:00
service/cfg: Make GenerateConsoleUniqueId() return a pair (#5321)
Same behavior, but allows the use of structured bindings.
This commit is contained in:
parent
41abdb505c
commit
30414eeb4b
@ -439,9 +439,7 @@ void ConfigureSystem::RefreshConsoleID() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 random_number;
|
const auto [random_number, console_id] = cfg->GenerateConsoleUniqueId();
|
||||||
u64 console_id;
|
|
||||||
cfg->GenerateConsoleUniqueId(random_number, console_id);
|
|
||||||
cfg->SetConsoleUniqueId(random_number, console_id);
|
cfg->SetConsoleUniqueId(random_number, console_id);
|
||||||
cfg->UpdateConfigNANDSavegame();
|
cfg->UpdateConfigNANDSavegame();
|
||||||
ui->label_console_id->setText(
|
ui->label_console_id->setText(
|
||||||
|
@ -465,9 +465,7 @@ ResultCode Module::FormatConfig() {
|
|||||||
if (!res.IsSuccess())
|
if (!res.IsSuccess())
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
u32 random_number;
|
const auto [random_number, console_id] = GenerateConsoleUniqueId();
|
||||||
u64 console_id;
|
|
||||||
GenerateConsoleUniqueId(random_number, console_id);
|
|
||||||
|
|
||||||
u64_le console_id_le = console_id;
|
u64_le console_id_le = console_id;
|
||||||
res = CreateConfigInfoBlk(ConsoleUniqueID1BlockID, sizeof(console_id_le), 0xE, &console_id_le);
|
res = CreateConfigInfoBlk(ConsoleUniqueID1BlockID, sizeof(console_id_le), 0xE, &console_id_le);
|
||||||
@ -727,13 +725,18 @@ u8 Module::GetCountryCode() {
|
|||||||
return block.country_code;
|
return block.country_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::GenerateConsoleUniqueId(u32& random_number, u64& console_id) {
|
std::pair<u32, u64> Module::GenerateConsoleUniqueId() const {
|
||||||
CryptoPP::AutoSeededRandomPool rng;
|
CryptoPP::AutoSeededRandomPool rng;
|
||||||
random_number = rng.GenerateWord32(0, 0xFFFF);
|
const u32 random_number = rng.GenerateWord32(0, 0xFFFF);
|
||||||
|
|
||||||
u64_le local_friend_code_seed;
|
u64_le local_friend_code_seed;
|
||||||
rng.GenerateBlock(reinterpret_cast<CryptoPP::byte*>(&local_friend_code_seed),
|
rng.GenerateBlock(reinterpret_cast<CryptoPP::byte*>(&local_friend_code_seed),
|
||||||
sizeof(local_friend_code_seed));
|
sizeof(local_friend_code_seed));
|
||||||
console_id = (local_friend_code_seed & 0x3FFFFFFFF) | (static_cast<u64>(random_number) << 48);
|
|
||||||
|
const u64 console_id =
|
||||||
|
(local_friend_code_seed & 0x3FFFFFFFF) | (static_cast<u64>(random_number) << 48);
|
||||||
|
|
||||||
|
return std::make_pair(random_number, console_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode Module::SetConsoleUniqueId(u32 random_number, u64 console_id) {
|
ResultCode Module::SetConsoleUniqueId(u32 random_number, u64 console_id) {
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/service.h"
|
||||||
@ -383,12 +384,13 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a new random console unique id.
|
* Generates a new random console unique id.
|
||||||
* @param random_number a random generated 16bit number stored at 0x90002, used for generating
|
*
|
||||||
* the
|
* @returns A pair containing a random number and a random console ID.
|
||||||
* console_id
|
*
|
||||||
* @param console_id the randomly created console id
|
* @note The random number is a random generated 16bit number stored at 0x90002, used for
|
||||||
|
* generating the console ID.
|
||||||
*/
|
*/
|
||||||
void GenerateConsoleUniqueId(u32& random_number, u64& console_id);
|
std::pair<u32, u64> GenerateConsoleUniqueId() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the random_number and the console unique id in the config savegame.
|
* Sets the random_number and the console unique id in the config savegame.
|
||||||
|
Loading…
Reference in New Issue
Block a user