Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #11353 from noahpistilli/fix-mail-account-generation
Set checksum for NWC24Config during creation
  • Loading branch information
AdmiralCurtiss committed Dec 29, 2022
2 parents 2a8f3e4 + c820204 commit 4bc94e4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Source/Core/Core/IOS/Network/KD/NWC24Config.cpp
Expand Up @@ -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)}
{
Expand All @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Core/IOS/Network/KD/NWC24Config.h
Expand Up @@ -46,7 +46,9 @@ class NWC24Config final
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;
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Core/IOS/Network/KD/NetKDRequest.cpp
Expand Up @@ -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);
}
Expand Down

0 comments on commit 4bc94e4

Please sign in to comment.