Set checksum for NWC24Config during creation

This commit is contained in:
Sketch 2022-12-19 17:20:29 -05:00
parent fb8aa9744e
commit c01ec96c92
3 changed files with 13 additions and 0 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,6 +38,15 @@ void NWC24Config::ReadConfig()
ResetConfig();
}
void NWC24Config::WriteCBK() const
{
constexpr FS::Modes public_modes{FS::Mode::ReadWrite, FS::Mode::ReadWrite, FS::Mode::ReadWrite};
m_fs->CreateFullPath(PID_KD, PID_KD, CBK_PATH, 0, public_modes);
const auto file = m_fs->CreateAndOpenFile(PID_KD, PID_KD, CBK_PATH, public_modes);
if (!file || !file->Write(&m_data, 1))
ERROR_LOG_FMT(IOS_WC24, "Failed to open or write WC24 config file");
}
void NWC24Config::WriteConfig() const
{
constexpr FS::Modes public_modes{FS::Mode::ReadWrite, FS::Mode::ReadWrite, FS::Mode::ReadWrite};

View File

@ -46,6 +46,7 @@ public:
explicit NWC24Config(std::shared_ptr<FS::FileSystem> fs);
void ReadConfig();
void WriteCBK() const;
void WriteConfig() const;
void ResetConfig();

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);
}