Merge pull request #11353 from noahpistilli/fix-mail-account-generation

Set checksum for NWC24Config during creation
This commit is contained in:
Admiral H. Curtiss 2022-12-29 17:08:10 +01:00 committed by GitHub
commit 4bc94e4629
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 3 deletions

View File

@ -15,6 +15,7 @@
namespace IOS::HLE::NWC24
{
constexpr const char CONFIG_PATH[] = "/" WII_WC24CONF_DIR "/nwc24msg.cfg";
constexpr const char CBK_PATH[] = "/" WII_WC24CONF_DIR "/nwc24msg.cbk";
NWC24Config::NWC24Config(std::shared_ptr<FS::FileSystem> fs) : m_fs{std::move(fs)}
{
@ -37,13 +38,23 @@ void NWC24Config::ReadConfig()
ResetConfig();
}
void NWC24Config::WriteCBK() const
{
WriteConfigToPath(CBK_PATH);
}
void NWC24Config::WriteConfig() const
{
WriteConfigToPath(CONFIG_PATH);
}
void NWC24Config::WriteConfigToPath(const std::string& path) const
{
constexpr FS::Modes public_modes{FS::Mode::ReadWrite, FS::Mode::ReadWrite, FS::Mode::ReadWrite};
m_fs->CreateFullPath(PID_KD, PID_KD, CONFIG_PATH, 0, public_modes);
const auto file = m_fs->CreateAndOpenFile(PID_KD, PID_KD, CONFIG_PATH, public_modes);
m_fs->CreateFullPath(PID_KD, PID_KD, path, 0, public_modes);
const auto file = m_fs->CreateAndOpenFile(PID_KD, PID_KD, path, public_modes);
if (!file || !file->Write(&m_data, 1))
ERROR_LOG_FMT(IOS_WC24, "Failed to open or write WC24 config file");
ERROR_LOG_FMT(IOS_WC24, "Failed to open or write WC24 config file at {}", path);
}
void NWC24Config::ResetConfig()

View File

@ -46,7 +46,9 @@ public:
explicit NWC24Config(std::shared_ptr<FS::FileSystem> fs);
void ReadConfig();
void WriteCBK() const;
void WriteConfig() const;
void WriteConfigToPath(const std::string& path) const;
void ResetConfig();
u32 CalculateNwc24ConfigChecksum() const;

View File

@ -397,7 +397,9 @@ std::optional<IPCReply> NetKDRequestDevice::IOCtl(const IOCtlRequest& request)
config.SetId(user_id);
config.IncrementIdGen();
config.SetCreationStage(NWC24::NWC24CreationStage::Generated);
config.SetChecksum(config.CalculateNwc24ConfigChecksum());
config.WriteConfig();
config.WriteCBK();
WriteReturnValue(ret, request.buffer_out);
}