service/cecd: Addressed comments, code cleanup
This commit is contained in:
parent
c89759f597
commit
69b3217394
@ -47,10 +47,10 @@ void Module::Interface::Open(Kernel::HLERequestContext& ctx) {
|
||||
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
||||
switch (path_type) {
|
||||
case CecDataPathType::CEC_PATH_ROOT_DIR:
|
||||
case CecDataPathType::CEC_PATH_MBOX_DIR:
|
||||
case CecDataPathType::CEC_PATH_INBOX_DIR:
|
||||
case CecDataPathType::CEC_PATH_OUTBOX_DIR: {
|
||||
case CecDataPathType::ROOT_DIR:
|
||||
case CecDataPathType::MBOX_DIR:
|
||||
case CecDataPathType::INBOX_DIR:
|
||||
case CecDataPathType::OUTBOX_DIR: {
|
||||
auto dir_result =
|
||||
Service::FS::OpenDirectoryFromArchive(cecd->cecd_system_save_data_archive, path);
|
||||
if (dir_result.Failed()) {
|
||||
@ -62,38 +62,38 @@ void Module::Interface::Open(Kernel::HLERequestContext& ctx) {
|
||||
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC,
|
||||
ErrorSummary::NotFound, ErrorLevel::Status));
|
||||
}
|
||||
rb.Push<u32>(0); /// Zero entries
|
||||
rb.Push<u32>(0); // Zero entries
|
||||
} else {
|
||||
constexpr u32 max_entries = 32; /// reasonable value, just over max boxes 24
|
||||
constexpr u32 max_entries = 32; // reasonable value, just over max boxes 24
|
||||
auto directory = dir_result.Unwrap();
|
||||
|
||||
/// Actual reading into vector seems to be required for entry count
|
||||
// Actual reading into vector seems to be required for entry count
|
||||
std::vector<FileSys::Entry> entries(max_entries);
|
||||
const u32 entry_count = directory->backend->Read(max_entries, entries.data());
|
||||
|
||||
LOG_DEBUG(Service_CECD, "Number of entries found: {}", entry_count);
|
||||
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.Push<u32>(entry_count); /// Entry count
|
||||
rb.Push<u32>(entry_count); // Entry count
|
||||
directory->backend->Close();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: { /// If not directory, then it is a file
|
||||
default: { // If not directory, then it is a file
|
||||
auto file_result =
|
||||
Service::FS::OpenFileFromArchive(cecd->cecd_system_save_data_archive, path, mode);
|
||||
if (file_result.Failed()) {
|
||||
LOG_DEBUG(Service_CECD, "Failed to open file: {}", path.AsString());
|
||||
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
|
||||
ErrorLevel::Status));
|
||||
rb.Push<u32>(0); /// No file size
|
||||
rb.Push<u32>(0); // No file size
|
||||
} else {
|
||||
session_data->file = std::move(file_result.Unwrap());
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.Push<u32>(session_data->file->backend->GetSize()); /// Return file size
|
||||
rb.Push<u32>(session_data->file->backend->GetSize()); // Return file size
|
||||
}
|
||||
|
||||
if (path_type == CecDataPathType::CEC_MBOX_PROGRAM_ID) {
|
||||
if (path_type == CecDataPathType::MBOX_PROGRAM_ID) {
|
||||
std::vector<u8> program_id(8);
|
||||
u64_le le_program_id = Kernel::g_current_process->codeset->program_id;
|
||||
std::memcpy(program_id.data(), &le_program_id, sizeof(u64));
|
||||
@ -128,15 +128,15 @@ void Module::Interface::Read(Kernel::HLERequestContext& ctx) {
|
||||
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
|
||||
switch (session_data->data_path_type) {
|
||||
case CecDataPathType::CEC_PATH_ROOT_DIR:
|
||||
case CecDataPathType::CEC_PATH_MBOX_DIR:
|
||||
case CecDataPathType::CEC_PATH_INBOX_DIR:
|
||||
case CecDataPathType::CEC_PATH_OUTBOX_DIR:
|
||||
case CecDataPathType::ROOT_DIR:
|
||||
case CecDataPathType::MBOX_DIR:
|
||||
case CecDataPathType::INBOX_DIR:
|
||||
case CecDataPathType::OUTBOX_DIR:
|
||||
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::CEC,
|
||||
ErrorSummary::NotFound, ErrorLevel::Status));
|
||||
rb.Push<u32>(0); /// No bytes read
|
||||
rb.Push<u32>(0); // No bytes read
|
||||
break;
|
||||
default: /// If not directory, then it is a file
|
||||
default: // If not directory, then it is a file
|
||||
std::vector<u8> buffer(write_buffer_size);
|
||||
const u32 bytes_read =
|
||||
session_data->file->backend->Read(0, write_buffer_size, buffer.data()).Unwrap();
|
||||
@ -168,16 +168,11 @@ void Module::Interface::ReadMessage(Kernel::HLERequestContext& ctx) {
|
||||
std::vector<u8> id_buffer(message_id_size);
|
||||
message_id_buffer.Read(id_buffer.data(), 0, message_id_size);
|
||||
|
||||
FileSys::Path message_path;
|
||||
if (is_outbox) {
|
||||
message_path = cecd->GetCecDataPathTypeAsString(CecDataPathType::CEC_PATH_OUTBOX_MSG,
|
||||
ncch_program_id, id_buffer)
|
||||
.data();
|
||||
} else { /// otherwise inbox
|
||||
message_path = cecd->GetCecDataPathTypeAsString(CecDataPathType::CEC_PATH_INBOX_MSG,
|
||||
ncch_program_id, id_buffer)
|
||||
.data();
|
||||
}
|
||||
FileSys::Path message_path =
|
||||
cecd->GetCecDataPathTypeAsString(is_outbox ? CecDataPathType::OUTBOX_MSG
|
||||
: CecDataPathType::INBOX_MSG,
|
||||
ncch_program_id, id_buffer)
|
||||
.data();
|
||||
|
||||
auto message_result =
|
||||
Service::FS::OpenFileFromArchive(cecd->cecd_system_save_data_archive, message_path, mode);
|
||||
@ -196,7 +191,7 @@ void Module::Interface::ReadMessage(Kernel::HLERequestContext& ctx) {
|
||||
} else {
|
||||
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
|
||||
ErrorLevel::Status));
|
||||
rb.Push<u32>(0); /// zero bytes read
|
||||
rb.Push<u32>(0); // zero bytes read
|
||||
}
|
||||
rb.PushMappedBuffer(message_id_buffer);
|
||||
rb.PushMappedBuffer(write_buffer);
|
||||
@ -217,22 +212,19 @@ void Module::Interface::ReadMessageWithHMAC(Kernel::HLERequestContext& ctx) {
|
||||
auto& hmac_key_buffer = rp.PopMappedBuffer();
|
||||
auto& write_buffer = rp.PopMappedBuffer();
|
||||
|
||||
// TODO verify message HMAC with the given key
|
||||
|
||||
FileSys::Mode mode;
|
||||
mode.read_flag.Assign(1);
|
||||
|
||||
std::vector<u8> id_buffer(message_id_size);
|
||||
message_id_buffer.Read(id_buffer.data(), 0, message_id_size);
|
||||
|
||||
FileSys::Path message_path;
|
||||
if (is_outbox) {
|
||||
message_path = cecd->GetCecDataPathTypeAsString(CecDataPathType::CEC_PATH_OUTBOX_MSG,
|
||||
ncch_program_id, id_buffer)
|
||||
.data();
|
||||
} else { /// otherwise inbox
|
||||
message_path = cecd->GetCecDataPathTypeAsString(CecDataPathType::CEC_PATH_INBOX_MSG,
|
||||
ncch_program_id, id_buffer)
|
||||
.data();
|
||||
}
|
||||
FileSys::Path message_path =
|
||||
cecd->GetCecDataPathTypeAsString(is_outbox ? CecDataPathType::OUTBOX_MSG
|
||||
: CecDataPathType::INBOX_MSG,
|
||||
ncch_program_id, id_buffer)
|
||||
.data();
|
||||
|
||||
auto message_result =
|
||||
Service::FS::OpenFileFromArchive(cecd->cecd_system_save_data_archive, message_path, mode);
|
||||
@ -251,7 +243,7 @@ void Module::Interface::ReadMessageWithHMAC(Kernel::HLERequestContext& ctx) {
|
||||
} else {
|
||||
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
|
||||
ErrorLevel::Status));
|
||||
rb.Push<u32>(0); /// zero bytes read
|
||||
rb.Push<u32>(0); // zero bytes read
|
||||
}
|
||||
|
||||
rb.PushMappedBuffer(message_id_buffer);
|
||||
@ -281,14 +273,14 @@ void Module::Interface::Write(Kernel::HLERequestContext& ctx) {
|
||||
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||
switch (session_data->data_path_type) {
|
||||
case CecDataPathType::CEC_PATH_ROOT_DIR:
|
||||
case CecDataPathType::CEC_PATH_MBOX_DIR:
|
||||
case CecDataPathType::CEC_PATH_INBOX_DIR:
|
||||
case CecDataPathType::CEC_PATH_OUTBOX_DIR:
|
||||
case CecDataPathType::ROOT_DIR:
|
||||
case CecDataPathType::MBOX_DIR:
|
||||
case CecDataPathType::INBOX_DIR:
|
||||
case CecDataPathType::OUTBOX_DIR:
|
||||
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::CEC,
|
||||
ErrorSummary::NotFound, ErrorLevel::Status));
|
||||
break;
|
||||
default: /// If not directory, then it is a file
|
||||
default: // If not directory, then it is a file
|
||||
std::vector<u8> buffer(read_buffer_size);
|
||||
read_buffer.Read(buffer.data(), 0, read_buffer_size);
|
||||
|
||||
@ -324,16 +316,11 @@ void Module::Interface::WriteMessage(Kernel::HLERequestContext& ctx) {
|
||||
std::vector<u8> id_buffer(message_id_size);
|
||||
message_id_buffer.Read(id_buffer.data(), 0, message_id_size);
|
||||
|
||||
FileSys::Path message_path;
|
||||
if (is_outbox) {
|
||||
message_path = cecd->GetCecDataPathTypeAsString(CecDataPathType::CEC_PATH_OUTBOX_MSG,
|
||||
ncch_program_id, id_buffer)
|
||||
.data();
|
||||
} else { /// otherwise inbox
|
||||
message_path = cecd->GetCecDataPathTypeAsString(CecDataPathType::CEC_PATH_INBOX_MSG,
|
||||
ncch_program_id, id_buffer)
|
||||
.data();
|
||||
}
|
||||
FileSys::Path message_path =
|
||||
cecd->GetCecDataPathTypeAsString(is_outbox ? CecDataPathType::OUTBOX_MSG
|
||||
: CecDataPathType::INBOX_MSG,
|
||||
ncch_program_id, id_buffer)
|
||||
.data();
|
||||
|
||||
auto message_result =
|
||||
Service::FS::OpenFileFromArchive(cecd->cecd_system_save_data_archive, message_path, mode);
|
||||
@ -373,6 +360,8 @@ void Module::Interface::WriteMessageWithHMAC(Kernel::HLERequestContext& ctx) {
|
||||
auto& hmac_key_buffer = rp.PopMappedBuffer();
|
||||
auto& message_id_buffer = rp.PopMappedBuffer();
|
||||
|
||||
// TODO verify message HMAC with the given key
|
||||
|
||||
FileSys::Mode mode;
|
||||
mode.write_flag.Assign(1);
|
||||
mode.create_flag.Assign(1);
|
||||
@ -380,16 +369,11 @@ void Module::Interface::WriteMessageWithHMAC(Kernel::HLERequestContext& ctx) {
|
||||
std::vector<u8> id_buffer(message_id_size);
|
||||
message_id_buffer.Read(id_buffer.data(), 0, message_id_size);
|
||||
|
||||
FileSys::Path message_path;
|
||||
if (is_outbox) {
|
||||
message_path = cecd->GetCecDataPathTypeAsString(CecDataPathType::CEC_PATH_OUTBOX_MSG,
|
||||
ncch_program_id, id_buffer)
|
||||
.data();
|
||||
} else { /// otherwise inbox
|
||||
message_path = cecd->GetCecDataPathTypeAsString(CecDataPathType::CEC_PATH_INBOX_MSG,
|
||||
ncch_program_id, id_buffer)
|
||||
.data();
|
||||
}
|
||||
FileSys::Path message_path =
|
||||
cecd->GetCecDataPathTypeAsString(is_outbox ? CecDataPathType::OUTBOX_MSG
|
||||
: CecDataPathType::INBOX_MSG,
|
||||
ncch_program_id, id_buffer)
|
||||
.data();
|
||||
|
||||
auto message_result =
|
||||
Service::FS::OpenFileFromArchive(cecd->cecd_system_save_data_archive, message_path, mode);
|
||||
@ -434,31 +418,25 @@ void Module::Interface::Delete(Kernel::HLERequestContext& ctx) {
|
||||
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||
switch (path_type) {
|
||||
case CecDataPathType::CEC_PATH_ROOT_DIR:
|
||||
case CecDataPathType::CEC_PATH_MBOX_DIR:
|
||||
case CecDataPathType::CEC_PATH_INBOX_DIR:
|
||||
case CecDataPathType::CEC_PATH_OUTBOX_DIR:
|
||||
case CecDataPathType::ROOT_DIR:
|
||||
case CecDataPathType::MBOX_DIR:
|
||||
case CecDataPathType::INBOX_DIR:
|
||||
case CecDataPathType::OUTBOX_DIR:
|
||||
rb.Push(Service::FS::DeleteDirectoryRecursivelyFromArchive(
|
||||
cecd->cecd_system_save_data_archive, path));
|
||||
break;
|
||||
default: /// If not directory, then it is a file
|
||||
default: // If not directory, then it is a file
|
||||
if (message_id_size == 0) {
|
||||
rb.Push(Service::FS::DeleteFileFromArchive(cecd->cecd_system_save_data_archive, path));
|
||||
} else {
|
||||
std::vector<u8> id_buffer(message_id_size);
|
||||
message_id_buffer.Read(id_buffer.data(), 0, message_id_size);
|
||||
|
||||
FileSys::Path message_path;
|
||||
if (is_outbox) {
|
||||
message_path =
|
||||
cecd->GetCecDataPathTypeAsString(CecDataPathType::CEC_PATH_OUTBOX_MSG,
|
||||
ncch_program_id, id_buffer)
|
||||
.data();
|
||||
} else { /// otherwise inbox
|
||||
message_path = cecd->GetCecDataPathTypeAsString(CecDataPathType::CEC_PATH_INBOX_MSG,
|
||||
ncch_program_id, id_buffer)
|
||||
.data();
|
||||
}
|
||||
FileSys::Path message_path =
|
||||
cecd->GetCecDataPathTypeAsString(is_outbox ? CecDataPathType::OUTBOX_MSG
|
||||
: CecDataPathType::INBOX_MSG,
|
||||
ncch_program_id, id_buffer)
|
||||
.data();
|
||||
rb.Push(Service::FS::DeleteFileFromArchive(cecd->cecd_system_save_data_archive,
|
||||
message_path));
|
||||
}
|
||||
@ -480,24 +458,6 @@ void Module::Interface::SetData(Kernel::HLERequestContext& ctx) {
|
||||
const u32 option = rp.Pop<u32>();
|
||||
auto& message_id_buffer = rp.PopMappedBuffer();
|
||||
|
||||
if (buffer_size > 0) {
|
||||
FileSys::Path path("/SetData.out");
|
||||
FileSys::Mode mode;
|
||||
mode.write_flag.Assign(1);
|
||||
mode.create_flag.Assign(1);
|
||||
|
||||
auto file_result =
|
||||
Service::FS::OpenFileFromArchive(cecd->cecd_system_save_data_archive, path, mode);
|
||||
if (file_result.Succeeded()) {
|
||||
auto file = file_result.Unwrap();
|
||||
std::vector<u8> buffer(buffer_size);
|
||||
message_id_buffer.Read(buffer.data(), 0, buffer_size);
|
||||
|
||||
file->backend->Write(0, buffer_size, true, buffer.data());
|
||||
file->backend->Close();
|
||||
}
|
||||
}
|
||||
|
||||
SessionData* session_data = GetSessionData(ctx.Session());
|
||||
if (session_data->file)
|
||||
LOG_TRACE(
|
||||
@ -529,20 +489,20 @@ void Module::Interface::ReadData(Kernel::HLERequestContext& ctx) {
|
||||
auto& param_buffer = rp.PopMappedBuffer();
|
||||
auto& dest_buffer = rp.PopMappedBuffer();
|
||||
|
||||
/// TODO: Other CecSystemInfoTypes
|
||||
// TODO: Other CecSystemInfoTypes
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
|
||||
std::vector<u8> buffer;
|
||||
switch (info_type) {
|
||||
case CecSystemInfoType::EulaVersion: /// TODO: Read config Eula version
|
||||
case CecSystemInfoType::EulaVersion: // TODO: Read config Eula version
|
||||
buffer = {0xFF, 0xFF};
|
||||
dest_buffer.Write(buffer.data(), 0, buffer.size());
|
||||
break;
|
||||
case CecSystemInfoType::Eula:
|
||||
buffer = {0x01}; /// Eula agreed
|
||||
buffer = {0x01}; // Eula agreed
|
||||
dest_buffer.Write(buffer.data(), 0, buffer.size());
|
||||
break;
|
||||
case CecSystemInfoType::ParentControl:
|
||||
buffer = {0x00}; /// No parent control
|
||||
buffer = {0x00}; // No parent control
|
||||
dest_buffer.Write(buffer.data(), 0, buffer.size());
|
||||
break;
|
||||
default:
|
||||
@ -639,14 +599,14 @@ void Module::Interface::OpenAndWrite(Kernel::HLERequestContext& ctx) {
|
||||
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||
switch (path_type) {
|
||||
case CecDataPathType::CEC_PATH_ROOT_DIR:
|
||||
case CecDataPathType::CEC_PATH_MBOX_DIR:
|
||||
case CecDataPathType::CEC_PATH_INBOX_DIR:
|
||||
case CecDataPathType::CEC_PATH_OUTBOX_DIR:
|
||||
case CecDataPathType::ROOT_DIR:
|
||||
case CecDataPathType::MBOX_DIR:
|
||||
case CecDataPathType::INBOX_DIR:
|
||||
case CecDataPathType::OUTBOX_DIR:
|
||||
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::CEC,
|
||||
ErrorSummary::NotFound, ErrorLevel::Status));
|
||||
break;
|
||||
default: /// If not directory, then it is a file
|
||||
default: // If not directory, then it is a file
|
||||
auto file_result =
|
||||
Service::FS::OpenFileFromArchive(cecd->cecd_system_save_data_archive, path, mode);
|
||||
if (file_result.Succeeded()) {
|
||||
@ -694,15 +654,15 @@ void Module::Interface::OpenAndRead(Kernel::HLERequestContext& ctx) {
|
||||
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
|
||||
switch (path_type) {
|
||||
case CecDataPathType::CEC_PATH_ROOT_DIR:
|
||||
case CecDataPathType::CEC_PATH_MBOX_DIR:
|
||||
case CecDataPathType::CEC_PATH_INBOX_DIR:
|
||||
case CecDataPathType::CEC_PATH_OUTBOX_DIR:
|
||||
case CecDataPathType::ROOT_DIR:
|
||||
case CecDataPathType::MBOX_DIR:
|
||||
case CecDataPathType::INBOX_DIR:
|
||||
case CecDataPathType::OUTBOX_DIR:
|
||||
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::CEC,
|
||||
ErrorSummary::NotFound, ErrorLevel::Status));
|
||||
rb.Push<u32>(0); /// No entries read
|
||||
rb.Push<u32>(0); // No entries read
|
||||
break;
|
||||
default: /// If not directory, then it is a file
|
||||
default: // If not directory, then it is a file
|
||||
auto file_result =
|
||||
Service::FS::OpenFileFromArchive(cecd->cecd_system_save_data_archive, path, mode);
|
||||
if (file_result.Succeeded()) {
|
||||
@ -718,7 +678,7 @@ void Module::Interface::OpenAndRead(Kernel::HLERequestContext& ctx) {
|
||||
} else {
|
||||
rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::CEC, ErrorSummary::NotFound,
|
||||
ErrorLevel::Status));
|
||||
rb.Push<u32>(0); /// No bytes read
|
||||
rb.Push<u32>(0); // No bytes read
|
||||
}
|
||||
}
|
||||
rb.PushMappedBuffer(write_buffer);
|
||||
@ -761,33 +721,33 @@ std::string Module::EncodeBase64(const std::vector<u8>& in, const std::string& d
|
||||
std::string Module::GetCecDataPathTypeAsString(const CecDataPathType type, const u32 program_id,
|
||||
const std::vector<u8>& msg_id) const {
|
||||
switch (type) {
|
||||
case CecDataPathType::CEC_PATH_MBOX_LIST:
|
||||
case CecDataPathType::MBOX_LIST:
|
||||
return "/CEC/MBoxList____";
|
||||
case CecDataPathType::CEC_PATH_MBOX_INFO:
|
||||
case CecDataPathType::MBOX_INFO:
|
||||
return fmt::format("/CEC/{:08x}/MBoxInfo____", program_id);
|
||||
case CecDataPathType::CEC_PATH_INBOX_INFO:
|
||||
case CecDataPathType::INBOX_INFO:
|
||||
return fmt::format("/CEC/{:08x}/InBox___/BoxInfo_____", program_id);
|
||||
case CecDataPathType::CEC_PATH_OUTBOX_INFO:
|
||||
case CecDataPathType::OUTBOX_INFO:
|
||||
return fmt::format("/CEC/{:08x}/OutBox__/BoxInfo_____", program_id);
|
||||
case CecDataPathType::CEC_PATH_OUTBOX_INDEX:
|
||||
case CecDataPathType::OUTBOX_INDEX:
|
||||
return fmt::format("/CEC/{:08x}/OutBox__/OBIndex_____", program_id);
|
||||
case CecDataPathType::CEC_PATH_INBOX_MSG:
|
||||
case CecDataPathType::INBOX_MSG:
|
||||
return fmt::format("/CEC/{:08x}/InBox___/_{}", program_id,
|
||||
EncodeBase64(msg_id, base64_dict));
|
||||
case CecDataPathType::CEC_PATH_OUTBOX_MSG:
|
||||
case CecDataPathType::OUTBOX_MSG:
|
||||
return fmt::format("/CEC/{:08x}/OutBox__/_{}", program_id,
|
||||
EncodeBase64(msg_id, base64_dict));
|
||||
case CecDataPathType::CEC_PATH_ROOT_DIR:
|
||||
case CecDataPathType::ROOT_DIR:
|
||||
return "/CEC";
|
||||
case CecDataPathType::CEC_PATH_MBOX_DIR:
|
||||
case CecDataPathType::MBOX_DIR:
|
||||
return fmt::format("/CEC/{:08x}", program_id);
|
||||
case CecDataPathType::CEC_PATH_INBOX_DIR:
|
||||
case CecDataPathType::INBOX_DIR:
|
||||
return fmt::format("/CEC/{:08x}/InBox___", program_id);
|
||||
case CecDataPathType::CEC_PATH_OUTBOX_DIR:
|
||||
case CecDataPathType::OUTBOX_DIR:
|
||||
return fmt::format("/CEC/{:08x}/OutBox__", program_id);
|
||||
case CecDataPathType::CEC_MBOX_DATA:
|
||||
case CecDataPathType::CEC_MBOX_ICON:
|
||||
case CecDataPathType::CEC_MBOX_TITLE:
|
||||
case CecDataPathType::MBOX_DATA:
|
||||
case CecDataPathType::MBOX_ICON:
|
||||
case CecDataPathType::MBOX_TITLE:
|
||||
default:
|
||||
return fmt::format("/CEC/{:08x}/MBoxData.{:03}", program_id, static_cast<u32>(type) - 100);
|
||||
}
|
||||
@ -795,49 +755,49 @@ std::string Module::GetCecDataPathTypeAsString(const CecDataPathType type, const
|
||||
|
||||
std::string Module::GetCecCommandAsString(const CecCommand command) const {
|
||||
switch (command) {
|
||||
case CecCommand::CEC_COMMAND_NONE:
|
||||
case CecCommand::NONE:
|
||||
return "NONE";
|
||||
case CecCommand::CEC_COMMAND_START:
|
||||
case CecCommand::START:
|
||||
return "START";
|
||||
case CecCommand::CEC_COMMAND_RESET_START:
|
||||
case CecCommand::RESET_START:
|
||||
return "RESET_START";
|
||||
case CecCommand::CEC_COMMAND_READYSCAN:
|
||||
case CecCommand::READYSCAN:
|
||||
return "READYSCAN";
|
||||
case CecCommand::CEC_COMMAND_READYSCANWAIT:
|
||||
case CecCommand::READYSCANWAIT:
|
||||
return "READYSCANWAIT";
|
||||
case CecCommand::CEC_COMMAND_STARTSCAN:
|
||||
case CecCommand::STARTSCAN:
|
||||
return "STARTSCAN";
|
||||
case CecCommand::CEC_COMMAND_RESCAN:
|
||||
case CecCommand::RESCAN:
|
||||
return "RESCAN";
|
||||
case CecCommand::CEC_COMMAND_NDM_RESUME:
|
||||
case CecCommand::NDM_RESUME:
|
||||
return "RESUME";
|
||||
case CecCommand::CEC_COMMAND_NDM_SUSPEND:
|
||||
case CecCommand::NDM_SUSPEND:
|
||||
return "NDM_SUSPEND";
|
||||
case CecCommand::CEC_COMMAND_NDM_SUSPEND_IMMEDIATE:
|
||||
case CecCommand::NDM_SUSPEND_IMMEDIATE:
|
||||
return "NDM_SUSPEND_IMMEDIATE";
|
||||
case CecCommand::CEC_COMMAND_STOPWAIT:
|
||||
case CecCommand::STOPWAIT:
|
||||
return "STOPWAIT";
|
||||
case CecCommand::CEC_COMMAND_STOP:
|
||||
case CecCommand::STOP:
|
||||
return "STOP";
|
||||
case CecCommand::CEC_COMMAND_STOP_FORCE:
|
||||
case CecCommand::STOP_FORCE:
|
||||
return "STOP_FORCE";
|
||||
case CecCommand::CEC_COMMAND_STOP_FORCE_WAIT:
|
||||
case CecCommand::STOP_FORCE_WAIT:
|
||||
return "STOP_FORCE_WAIT";
|
||||
case CecCommand::CEC_COMMAND_RESET_FILTER:
|
||||
case CecCommand::RESET_FILTER:
|
||||
return "RESET_FILTER";
|
||||
case CecCommand::CEC_COMMAND_DAEMON_STOP:
|
||||
case CecCommand::DAEMON_STOP:
|
||||
return "DAEMON_STOP";
|
||||
case CecCommand::CEC_COMMAND_DAEMON_START:
|
||||
case CecCommand::DAEMON_START:
|
||||
return "DAEMON_START";
|
||||
case CecCommand::CEC_COMMAND_EXIT:
|
||||
case CecCommand::EXIT:
|
||||
return "EXIT";
|
||||
case CecCommand::CEC_COMMAND_OVER_BOSS:
|
||||
case CecCommand::OVER_BOSS:
|
||||
return "OVER_BOSS";
|
||||
case CecCommand::CEC_COMMAND_OVER_BOSS_FORCE:
|
||||
case CecCommand::OVER_BOSS_FORCE:
|
||||
return "OVER_BOSS_FORCE";
|
||||
case CecCommand::CEC_COMMAND_OVER_BOSS_FORCE_WAIT:
|
||||
case CecCommand::OVER_BOSS_FORCE_WAIT:
|
||||
return "OVER_BOSS_FORCE_WAIT";
|
||||
case CecCommand::CEC_COMMAND_END:
|
||||
case CecCommand::END:
|
||||
return "END";
|
||||
default:
|
||||
return "Unknown";
|
||||
@ -847,20 +807,20 @@ std::string Module::GetCecCommandAsString(const CecCommand command) const {
|
||||
void Module::CheckAndUpdateFile(const CecDataPathType path_type, const u32 ncch_program_id,
|
||||
std::vector<u8>& file_buffer) {
|
||||
constexpr u32 max_num_boxes = 24;
|
||||
constexpr u32 name_size = 16; /// fixed size 16 characters long
|
||||
constexpr u32 valid_name_size = 8; /// 8 characters are valid, the rest are null
|
||||
constexpr u32 name_size = 16; // fixed size 16 characters long
|
||||
constexpr u32 valid_name_size = 8; // 8 characters are valid, the rest are null
|
||||
const u32 file_size = file_buffer.size();
|
||||
|
||||
switch (path_type) {
|
||||
case CecDataPathType::CEC_PATH_MBOX_LIST: {
|
||||
case CecDataPathType::MBOX_LIST: {
|
||||
CecMBoxListHeader mbox_list_header = {};
|
||||
std::memcpy(&mbox_list_header, file_buffer.data(), sizeof(CecMBoxListHeader));
|
||||
|
||||
if (file_size != sizeof(CecMBoxListHeader)) { /// 0x18C
|
||||
if (file_size != sizeof(CecMBoxListHeader)) { // 0x18C
|
||||
LOG_DEBUG(Service_CECD, "CecMBoxListHeader size is incorrect: {}", file_size);
|
||||
}
|
||||
|
||||
if (mbox_list_header.magic != 0x6868) { /// 'hh'
|
||||
if (mbox_list_header.magic != 0x6868) { // 'hh'
|
||||
if (mbox_list_header.magic == 0 || mbox_list_header.magic == 0xFFFF) {
|
||||
LOG_DEBUG(Service_CECD, "CecMBoxListHeader magic number is not set");
|
||||
} else {
|
||||
@ -871,7 +831,7 @@ void Module::CheckAndUpdateFile(const CecDataPathType path_type, const u32 ncch_
|
||||
mbox_list_header.magic = 0x6868;
|
||||
}
|
||||
|
||||
if (mbox_list_header.version != 0x01) { /// Not quite sure if it is a version
|
||||
if (mbox_list_header.version != 0x01) { // Not quite sure if it is a version
|
||||
if (mbox_list_header.version == 0)
|
||||
LOG_DEBUG(Service_CECD, "CecMBoxListHeader version is not set");
|
||||
else
|
||||
@ -894,8 +854,8 @@ void Module::CheckAndUpdateFile(const CecDataPathType path_type, const u32 ncch_
|
||||
bool already_activated = false;
|
||||
for (auto i = 0; i < mbox_list_header.num_boxes; i++) {
|
||||
LOG_DEBUG(Service_CECD, "{}", i);
|
||||
/// Box names start at offset 0xC, are 16 char long, first 8 id, last 8 null
|
||||
if (std::memcmp(name_buffer.data(), &mbox_list_header.box_names[i * name_size],
|
||||
// Box names start at offset 0xC, are 16 char long, first 8 id, last 8 null
|
||||
if (std::memcmp(name_buffer.data(), &mbox_list_header.box_names[i],
|
||||
valid_name_size) == 0) {
|
||||
LOG_DEBUG(Service_CECD, "Title already activated");
|
||||
already_activated = true;
|
||||
@ -903,20 +863,19 @@ void Module::CheckAndUpdateFile(const CecDataPathType path_type, const u32 ncch_
|
||||
};
|
||||
|
||||
if (!already_activated) {
|
||||
if (mbox_list_header.num_boxes < max_num_boxes) { /// max boxes
|
||||
if (mbox_list_header.num_boxes < max_num_boxes) { // max boxes
|
||||
LOG_DEBUG(Service_CECD, "Adding title to mboxlist____: {}", name);
|
||||
std::memcpy(
|
||||
&mbox_list_header.box_names[mbox_list_header.num_boxes * name_size],
|
||||
name_buffer.data(), name_size);
|
||||
std::memcpy(&mbox_list_header.box_names[mbox_list_header.num_boxes],
|
||||
name_buffer.data(), name_size);
|
||||
mbox_list_header.num_boxes++;
|
||||
}
|
||||
}
|
||||
} else { /// ncch_program_id == 0, remove/update activated boxes
|
||||
} else { // ncch_program_id == 0, remove/update activated boxes
|
||||
/// We need to read the /CEC directory to find out which titles, if any,
|
||||
/// are activated. The num_of_titles = (total_read_count) - 1, to adjust for
|
||||
/// the MBoxList____ file that is present in the directory as well.
|
||||
FileSys::Path root_path(
|
||||
GetCecDataPathTypeAsString(CecDataPathType::CEC_PATH_ROOT_DIR, 0).data());
|
||||
GetCecDataPathTypeAsString(CecDataPathType::ROOT_DIR, 0).data());
|
||||
|
||||
auto dir_result =
|
||||
Service::FS::OpenDirectoryFromArchive(cecd_system_save_data_archive, root_path);
|
||||
@ -932,14 +891,14 @@ void Module::CheckAndUpdateFile(const CecDataPathType path_type, const u32 ncch_
|
||||
std::string file_name;
|
||||
std::u16string u16_filename;
|
||||
|
||||
/// Loop through entries but don't add mboxlist____ to itself.
|
||||
// Loop through entries but don't add mboxlist____ to itself.
|
||||
for (auto i = 0; i < entry_count; i++) {
|
||||
u16_filename = std::u16string(entries[i].filename);
|
||||
file_name = Common::UTF16ToUTF8(u16_filename);
|
||||
|
||||
if (mbox_list_name.compare(file_name) != 0) {
|
||||
LOG_DEBUG(Service_CECD, "Adding title to mboxlist____: {}", file_name);
|
||||
std::memcpy(&mbox_list_header.box_names[16 * mbox_list_header.num_boxes++],
|
||||
std::memcpy(&mbox_list_header.box_names[mbox_list_header.num_boxes++],
|
||||
file_name.data(), valid_name_size);
|
||||
}
|
||||
}
|
||||
@ -948,15 +907,15 @@ void Module::CheckAndUpdateFile(const CecDataPathType path_type, const u32 ncch_
|
||||
std::memcpy(file_buffer.data(), &mbox_list_header, sizeof(CecMBoxListHeader));
|
||||
break;
|
||||
}
|
||||
case CecDataPathType::CEC_PATH_MBOX_INFO: {
|
||||
case CecDataPathType::MBOX_INFO: {
|
||||
CecMBoxInfoHeader mbox_info_header = {};
|
||||
std::memcpy(&mbox_info_header, file_buffer.data(), sizeof(CecMBoxInfoHeader));
|
||||
|
||||
if (file_size != sizeof(CecMBoxInfoHeader)) { /// 0x60
|
||||
if (file_size != sizeof(CecMBoxInfoHeader)) { // 0x60
|
||||
LOG_DEBUG(Service_CECD, "CecMBoxInfoHeader size is incorrect: {}", file_size);
|
||||
}
|
||||
|
||||
if (mbox_info_header.magic != 0x6363) { /// 'cc'
|
||||
if (mbox_info_header.magic != 0x6363) { // 'cc'
|
||||
if (mbox_info_header.magic == 0)
|
||||
LOG_DEBUG(Service_CECD, "CecMBoxInfoHeader magic number is not set");
|
||||
else
|
||||
@ -976,11 +935,11 @@ void Module::CheckAndUpdateFile(const CecDataPathType path_type, const u32 ncch_
|
||||
std::memcpy(file_buffer.data(), &mbox_info_header, sizeof(CecMBoxInfoHeader));
|
||||
break;
|
||||
}
|
||||
case CecDataPathType::CEC_PATH_INBOX_INFO: {
|
||||
case CecDataPathType::INBOX_INFO: {
|
||||
CecInOutBoxInfoHeader inbox_info_header = {};
|
||||
std::memcpy(&inbox_info_header, file_buffer.data(), sizeof(CecInOutBoxInfoHeader));
|
||||
|
||||
if (inbox_info_header.magic != 0x6262) { /// 'bb'
|
||||
if (inbox_info_header.magic != 0x6262) { // 'bb'
|
||||
if (inbox_info_header.magic == 0)
|
||||
LOG_DEBUG(Service_CECD, "CecInBoxInfoHeader magic number is not set");
|
||||
else
|
||||
@ -1028,11 +987,11 @@ void Module::CheckAndUpdateFile(const CecDataPathType path_type, const u32 ncch_
|
||||
std::memcpy(file_buffer.data(), &inbox_info_header, sizeof(CecInOutBoxInfoHeader));
|
||||
break;
|
||||
}
|
||||
case CecDataPathType::CEC_PATH_OUTBOX_INFO: {
|
||||
case CecDataPathType::OUTBOX_INFO: {
|
||||
CecInOutBoxInfoHeader outbox_info_header = {};
|
||||
std::memcpy(&outbox_info_header, file_buffer.data(), sizeof(CecInOutBoxInfoHeader));
|
||||
|
||||
if (outbox_info_header.magic != 0x6262) { /// 'bb'
|
||||
if (outbox_info_header.magic != 0x6262) { // 'bb'
|
||||
if (outbox_info_header.magic == 0)
|
||||
LOG_DEBUG(Service_CECD, "CecOutBoxInfoHeader magic number is not set");
|
||||
else
|
||||
@ -1078,15 +1037,15 @@ void Module::CheckAndUpdateFile(const CecDataPathType path_type, const u32 ncch_
|
||||
std::memcpy(file_buffer.data(), &outbox_info_header, sizeof(CecInOutBoxInfoHeader));
|
||||
break;
|
||||
}
|
||||
case CecDataPathType::CEC_PATH_OUTBOX_INDEX: {
|
||||
case CecDataPathType::OUTBOX_INDEX: {
|
||||
CecOBIndexHeader obindex_header = {};
|
||||
std::memcpy(&obindex_header, file_buffer.data(), sizeof(CecOBIndexHeader));
|
||||
|
||||
if (file_size < sizeof(CecOBIndexHeader)) { /// 0x08, minimum size
|
||||
if (file_size < sizeof(CecOBIndexHeader)) { // 0x08, minimum size
|
||||
LOG_DEBUG(Service_CECD, "CecOBIndexHeader size is too small: {}", file_size);
|
||||
}
|
||||
|
||||
if (obindex_header.magic != 0x6767) { /// 'gg'
|
||||
if (obindex_header.magic != 0x6767) { // 'gg'
|
||||
if (obindex_header.magic == 0)
|
||||
LOG_DEBUG(Service_CECD, "CecOBIndexHeader magic number is not set");
|
||||
else
|
||||
@ -1098,7 +1057,7 @@ void Module::CheckAndUpdateFile(const CecDataPathType path_type, const u32 ncch_
|
||||
if (obindex_header.message_num == 0) {
|
||||
if (file_size > sizeof(CecOBIndexHeader)) {
|
||||
LOG_DEBUG(Service_CECD, "CecOBIndexHeader message number is not set");
|
||||
obindex_header.message_num = (file_size % 8) - 1; /// 8 byte message id - 1 header
|
||||
obindex_header.message_num = (file_size % 8) - 1; // 8 byte message id - 1 header
|
||||
}
|
||||
} else if (obindex_header.message_num != (file_size % 8) - 1) {
|
||||
LOG_DEBUG(Service_CECD, "CecOBIndexHeader message number is incorrect: {}",
|
||||
@ -1108,18 +1067,18 @@ void Module::CheckAndUpdateFile(const CecDataPathType path_type, const u32 ncch_
|
||||
std::memcpy(file_buffer.data(), &obindex_header, sizeof(CecOBIndexHeader));
|
||||
break;
|
||||
}
|
||||
case CecDataPathType::CEC_PATH_INBOX_MSG:
|
||||
case CecDataPathType::INBOX_MSG:
|
||||
break;
|
||||
case CecDataPathType::CEC_PATH_OUTBOX_MSG:
|
||||
case CecDataPathType::OUTBOX_MSG:
|
||||
break;
|
||||
case CecDataPathType::CEC_PATH_ROOT_DIR:
|
||||
case CecDataPathType::CEC_PATH_MBOX_DIR:
|
||||
case CecDataPathType::CEC_PATH_INBOX_DIR:
|
||||
case CecDataPathType::CEC_PATH_OUTBOX_DIR:
|
||||
case CecDataPathType::ROOT_DIR:
|
||||
case CecDataPathType::MBOX_DIR:
|
||||
case CecDataPathType::INBOX_DIR:
|
||||
case CecDataPathType::OUTBOX_DIR:
|
||||
break;
|
||||
case CecDataPathType::CEC_MBOX_DATA:
|
||||
case CecDataPathType::CEC_MBOX_ICON:
|
||||
case CecDataPathType::CEC_MBOX_TITLE:
|
||||
case CecDataPathType::MBOX_DATA:
|
||||
case CecDataPathType::MBOX_ICON:
|
||||
case CecDataPathType::MBOX_TITLE:
|
||||
default: {}
|
||||
}
|
||||
}
|
||||
@ -1157,7 +1116,7 @@ Module::Module() {
|
||||
/// Now that the archive is formatted, we need to create the root CEC directory,
|
||||
/// eventlog.dat, and CEC/MBoxList____
|
||||
const FileSys::Path root_dir_path(
|
||||
GetCecDataPathTypeAsString(CecDataPathType::CEC_PATH_ROOT_DIR, 0).data());
|
||||
GetCecDataPathTypeAsString(CecDataPathType::ROOT_DIR, 0).data());
|
||||
Service::FS::CreateDirectoryFromArchive(*archive_result, root_dir_path);
|
||||
|
||||
FileSys::Mode mode;
|
||||
@ -1191,7 +1150,7 @@ Module::Module() {
|
||||
/// being the magic number. The rest of the file is filled with zeroes, until the end of
|
||||
/// file at offset 0x18b
|
||||
FileSys::Path mboxlist_path(
|
||||
GetCecDataPathTypeAsString(CecDataPathType::CEC_PATH_MBOX_LIST, 0).data());
|
||||
GetCecDataPathTypeAsString(CecDataPathType::MBOX_LIST, 0).data());
|
||||
|
||||
auto mboxlist_result =
|
||||
Service::FS::OpenFileFromArchive(*archive_result, mboxlist_path, mode);
|
||||
@ -1203,7 +1162,7 @@ Module::Module() {
|
||||
std::memset(&mboxlist_buffer[0], 0, mboxlist_size);
|
||||
mboxlist_buffer[0] = 0x68;
|
||||
mboxlist_buffer[1] = 0x68;
|
||||
/// mboxlist_buffer[2-3] are already zeroed
|
||||
// mboxlist_buffer[2-3] are already zeroed
|
||||
mboxlist_buffer[4] = 0x01;
|
||||
|
||||
mboxlist->backend->Write(0, mboxlist_size, true, mboxlist_buffer.data());
|
||||
|
@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/bit_field.h"
|
||||
#include "common/common_funcs.h"
|
||||
#include "core/hle/kernel/event.h"
|
||||
#include "core/hle/service/fs/archive.h"
|
||||
#include "core/hle/service/service.h"
|
||||
@ -18,28 +19,28 @@ public:
|
||||
~Module();
|
||||
|
||||
enum class CecCommand : u32 {
|
||||
CEC_COMMAND_NONE = 0,
|
||||
CEC_COMMAND_START = 1,
|
||||
CEC_COMMAND_RESET_START = 2,
|
||||
CEC_COMMAND_READYSCAN = 3,
|
||||
CEC_COMMAND_READYSCANWAIT = 4,
|
||||
CEC_COMMAND_STARTSCAN = 5,
|
||||
CEC_COMMAND_RESCAN = 6,
|
||||
CEC_COMMAND_NDM_RESUME = 7,
|
||||
CEC_COMMAND_NDM_SUSPEND = 8,
|
||||
CEC_COMMAND_NDM_SUSPEND_IMMEDIATE = 9,
|
||||
CEC_COMMAND_STOPWAIT = 0x0A,
|
||||
CEC_COMMAND_STOP = 0x0B,
|
||||
CEC_COMMAND_STOP_FORCE = 0x0C,
|
||||
CEC_COMMAND_STOP_FORCE_WAIT = 0x0D,
|
||||
CEC_COMMAND_RESET_FILTER = 0x0E,
|
||||
CEC_COMMAND_DAEMON_STOP = 0x0F,
|
||||
CEC_COMMAND_DAEMON_START = 0x10,
|
||||
CEC_COMMAND_EXIT = 0x11,
|
||||
CEC_COMMAND_OVER_BOSS = 0x12,
|
||||
CEC_COMMAND_OVER_BOSS_FORCE = 0x13,
|
||||
CEC_COMMAND_OVER_BOSS_FORCE_WAIT = 0x14,
|
||||
CEC_COMMAND_END = 0x15,
|
||||
NONE = 0,
|
||||
START = 1,
|
||||
RESET_START = 2,
|
||||
READYSCAN = 3,
|
||||
READYSCANWAIT = 4,
|
||||
STARTSCAN = 5,
|
||||
RESCAN = 6,
|
||||
NDM_RESUME = 7,
|
||||
NDM_SUSPEND = 8,
|
||||
NDM_SUSPEND_IMMEDIATE = 9,
|
||||
STOPWAIT = 0x0A,
|
||||
STOP = 0x0B,
|
||||
STOP_FORCE = 0x0C,
|
||||
STOP_FORCE_WAIT = 0x0D,
|
||||
RESET_FILTER = 0x0E,
|
||||
DAEMON_STOP = 0x0F,
|
||||
DAEMON_START = 0x10,
|
||||
EXIT = 0x11,
|
||||
OVER_BOSS = 0x12,
|
||||
OVER_BOSS_FORCE = 0x13,
|
||||
OVER_BOSS_FORCE_WAIT = 0x14,
|
||||
END = 0x15,
|
||||
};
|
||||
|
||||
/**
|
||||
@ -49,59 +50,59 @@ public:
|
||||
* data:/CEC/test
|
||||
*/
|
||||
enum class CecDataPathType : u32 {
|
||||
CEC_PATH_INVALID = 0,
|
||||
CEC_PATH_MBOX_LIST = 1, /// data:/CEC/MBoxList____
|
||||
CEC_PATH_MBOX_INFO = 2, /// data:/CEC/<id>/MBoxInfo____
|
||||
CEC_PATH_INBOX_INFO = 3, /// data:/CEC/<id>/InBox___/BoxInfo_____
|
||||
CEC_PATH_OUTBOX_INFO = 4, /// data:/CEC/<id>/OutBox__/BoxInfo_____
|
||||
CEC_PATH_OUTBOX_INDEX = 5, /// data:/CEC/<id>/OutBox__/OBIndex_____
|
||||
CEC_PATH_INBOX_MSG = 6, /// data:/CEC/<id>/InBox___/_<message_id>
|
||||
CEC_PATH_OUTBOX_MSG = 7, /// data:/CEC/<id>/OutBox__/_<message_id>
|
||||
CEC_PATH_ROOT_DIR = 10, /// data:/CEC
|
||||
CEC_PATH_MBOX_DIR = 11, /// data:/CEC/<id>
|
||||
CEC_PATH_INBOX_DIR = 12, /// data:/CEC/<id>/InBox___
|
||||
CEC_PATH_OUTBOX_DIR = 13, /// data:/CEC/<id>/OutBox__
|
||||
CEC_MBOX_DATA = 100, /// data:/CEC/<id>/MBoxData.0<i-100>
|
||||
CEC_MBOX_ICON = 101, /// data:/CEC/<id>/MBoxData.001
|
||||
CEC_MBOX_TITLE = 110, /// data:/CEC/<id>/MBoxData.010
|
||||
CEC_MBOX_PROGRAM_ID = 150, /// data:/CEC/<id>/MBoxData.050
|
||||
INVALID = 0,
|
||||
MBOX_LIST = 1, /// data:/CEC/MBoxList____
|
||||
MBOX_INFO = 2, /// data:/CEC/<id>/MBoxInfo____
|
||||
INBOX_INFO = 3, /// data:/CEC/<id>/InBox___/BoxInfo_____
|
||||
OUTBOX_INFO = 4, /// data:/CEC/<id>/OutBox__/BoxInfo_____
|
||||
OUTBOX_INDEX = 5, /// data:/CEC/<id>/OutBox__/OBIndex_____
|
||||
INBOX_MSG = 6, /// data:/CEC/<id>/InBox___/_<message_id>
|
||||
OUTBOX_MSG = 7, /// data:/CEC/<id>/OutBox__/_<message_id>
|
||||
ROOT_DIR = 10, /// data:/CEC
|
||||
MBOX_DIR = 11, /// data:/CEC/<id>
|
||||
INBOX_DIR = 12, /// data:/CEC/<id>/InBox___
|
||||
OUTBOX_DIR = 13, /// data:/CEC/<id>/OutBox__
|
||||
MBOX_DATA = 100, /// data:/CEC/<id>/MBoxData.0<i-100>
|
||||
MBOX_ICON = 101, /// data:/CEC/<id>/MBoxData.001
|
||||
MBOX_TITLE = 110, /// data:/CEC/<id>/MBoxData.010
|
||||
MBOX_PROGRAM_ID = 150, /// data:/CEC/<id>/MBoxData.050
|
||||
};
|
||||
|
||||
enum class CecState : u32 {
|
||||
CEC_STATE_NONE = 0,
|
||||
CEC_STATE_INIT = 1,
|
||||
CEC_STATE_WIRELESS_PARAM_SETUP = 2,
|
||||
CEC_STATE_WIRELESS_READY = 3,
|
||||
CEC_STATE_WIRELESS_START_CONFIG = 4,
|
||||
CEC_STATE_SCAN = 5,
|
||||
CEC_STATE_SCANNING = 6,
|
||||
CEC_STATE_CONNECT = 7,
|
||||
CEC_STATE_CONNECTING = 8,
|
||||
CEC_STATE_CONNECTED = 9,
|
||||
CEC_STATE_CONNECT_TCP = 10,
|
||||
CEC_STATE_CONNECTING_TCP = 11,
|
||||
CEC_STATE_CONNECTED_TCP = 12,
|
||||
CEC_STATE_NEGOTIATION = 13,
|
||||
CEC_STATE_SEND_RECV_START = 14,
|
||||
CEC_STATE_SEND_RECV_INIT = 15,
|
||||
CEC_STATE_SEND_READY = 16,
|
||||
CEC_STATE_RECEIVE_READY = 17,
|
||||
CEC_STATE_RECEIVE = 18,
|
||||
CEC_STATE_CONNECTION_FINISH_TCP = 19,
|
||||
CEC_STATE_CONNECTION_FINISH = 20,
|
||||
CEC_STATE_SEND_POST = 21,
|
||||
CEC_STATE_RECEIVE_POST = 22,
|
||||
CEC_STATE_FINISHING = 23,
|
||||
CEC_STATE_FINISH = 24,
|
||||
CEC_STATE_OVER_BOSS = 25,
|
||||
CEC_STATE_IDLE = 26
|
||||
NONE = 0,
|
||||
INIT = 1,
|
||||
WIRELESS_PARAM_SETUP = 2,
|
||||
WIRELESS_READY = 3,
|
||||
WIRELESS_START_CONFIG = 4,
|
||||
SCAN = 5,
|
||||
SCANNING = 6,
|
||||
CONNECT = 7,
|
||||
CONNECTING = 8,
|
||||
CONNECTED = 9,
|
||||
CONNECT_TCP = 10,
|
||||
CONNECTING_TCP = 11,
|
||||
CONNECTED_TCP = 12,
|
||||
NEGOTIATION = 13,
|
||||
SEND_RECV_START = 14,
|
||||
SEND_RECV_INIT = 15,
|
||||
SEND_READY = 16,
|
||||
RECEIVE_READY = 17,
|
||||
RECEIVE = 18,
|
||||
CONNECTION_FINISH_TCP = 19,
|
||||
CONNECTION_FINISH = 20,
|
||||
SEND_POST = 21,
|
||||
RECEIVE_POST = 22,
|
||||
FINISHING = 23,
|
||||
FINISH = 24,
|
||||
OVER_BOSS = 25,
|
||||
IDLE = 26
|
||||
};
|
||||
|
||||
enum class CecSystemInfoType : u32 { EulaVersion = 1, Eula = 2, ParentControl = 3 };
|
||||
|
||||
struct CecInOutBoxInfoHeader {
|
||||
u16_le magic; // 0x6262 'bb'
|
||||
u16_le padding;
|
||||
INSERT_PADDING_BYTES(2);
|
||||
u32_le box_info_size;
|
||||
u32_le max_box_size;
|
||||
u32_le box_size;
|
||||
@ -115,15 +116,14 @@ public:
|
||||
|
||||
struct CecMBoxInfoHeader {
|
||||
u16_le magic; // 0x6363 'cc'
|
||||
u16_le padding;
|
||||
INSERT_PADDING_BYTES(2);
|
||||
u32_le program_id;
|
||||
u32_le private_id;
|
||||
u8 flag;
|
||||
u8 flag2;
|
||||
u16_le padding2;
|
||||
u8 hmac_key[32];
|
||||
u32_le padding3;
|
||||
/// year, 4 bytes, month 1 byte, day 1 byte, hour 1 byte, minute 1 byte
|
||||
INSERT_PADDING_BYTES(2);
|
||||
std::array<u8, 32> hmac_key;
|
||||
INSERT_PADDING_BYTES(4);
|
||||
struct Time {
|
||||
u32_le year;
|
||||
u8 month;
|
||||
@ -135,9 +135,9 @@ public:
|
||||
u8 microsecond;
|
||||
u8 padding;
|
||||
} last_accessed;
|
||||
u32_le padding4;
|
||||
INSERT_PADDING_BYTES(4);
|
||||
Time last_received;
|
||||
u32_le padding5;
|
||||
INSERT_PADDING_BYTES(4);
|
||||
Time unknown_time;
|
||||
};
|
||||
static_assert(sizeof(CecMBoxInfoHeader) == 0x60,
|
||||
@ -145,19 +145,19 @@ public:
|
||||
|
||||
struct CecMBoxListHeader {
|
||||
u16_le magic; // 0x6868 'hh'
|
||||
u16_le padding;
|
||||
u16_le version; /// 0x01 00, maybe activated flag?
|
||||
u16_le padding2;
|
||||
u16_le num_boxes; /// 24 max
|
||||
u16_le padding3;
|
||||
u8 box_names[16 * 24]; /// 16 char names, 24 boxes
|
||||
INSERT_PADDING_BYTES(2);
|
||||
u16_le version; // 0x01 00, maybe activated flag?
|
||||
INSERT_PADDING_BYTES(2);
|
||||
u16_le num_boxes; // 24 max
|
||||
INSERT_PADDING_BYTES(2);
|
||||
std::array<std::array<u8, 16>, 24> box_names; // 16 char names, 24 boxes
|
||||
};
|
||||
static_assert(sizeof(CecMBoxListHeader) == 0x18C,
|
||||
"CecMBoxListHeader struct has incorrect size.");
|
||||
|
||||
struct CecMessageHeader {
|
||||
u16_le magic; // ``
|
||||
u16_le padding;
|
||||
u16_le magic; // 0x6060 ``
|
||||
INSERT_PADDING_BYTES(2);
|
||||
u32_le message_size;
|
||||
u32_le header_size;
|
||||
u32_le body_size;
|
||||
@ -167,9 +167,9 @@ public:
|
||||
u32_le batch_id;
|
||||
u32_le unknown_id;
|
||||
|
||||
u8 message_id[8];
|
||||
std::array<u8, 8> message_id;
|
||||
u32_le version;
|
||||
u8 message_id_2[8];
|
||||
std::array<u8, 8> message_id_2;
|
||||
u8 flag;
|
||||
u8 send_method;
|
||||
u8 is_unopen;
|
||||
@ -177,7 +177,15 @@ public:
|
||||
u64_le sender_id;
|
||||
u64_le sender_id2;
|
||||
struct Time {
|
||||
u32_le a, b, c;
|
||||
u32_le year;
|
||||
u8 month;
|
||||
u8 day;
|
||||
u8 hour;
|
||||
u8 minute;
|
||||
u8 second;
|
||||
u8 millisecond;
|
||||
u8 microsecond;
|
||||
u8 padding;
|
||||
} send_time, recv_time, create_time;
|
||||
u8 send_count;
|
||||
u8 foward_count;
|
||||
@ -186,10 +194,10 @@ public:
|
||||
static_assert(sizeof(CecMessageHeader) == 0x70, "CecMessageHeader struct has incorrect size.");
|
||||
|
||||
struct CecOBIndexHeader {
|
||||
u16_le magic; /// 0x6767 'gg'
|
||||
u16_le padding;
|
||||
u16_le magic; // 0x6767 'gg'
|
||||
INSERT_PADDING_BYTES(2);
|
||||
u32_le message_num;
|
||||
/// Array? of messageid's 8 bytes each, same as CecMessageHeader.message_id[8]
|
||||
// Array of messageid's 8 bytes each, same as CecMessageHeader.message_id[8]
|
||||
};
|
||||
static_assert(sizeof(CecOBIndexHeader) == 0x08, "CecOBIndexHeader struct has incorrect size.");
|
||||
|
||||
@ -202,11 +210,11 @@ public:
|
||||
|
||||
union CecOpenMode {
|
||||
u32 raw;
|
||||
BitField<0, 1, u32> unknown; /// 1 delete?
|
||||
BitField<1, 1, u32> read; /// 2
|
||||
BitField<2, 1, u32> write; /// 4
|
||||
BitField<3, 1, u32> create; /// 8
|
||||
BitField<4, 1, u32> check; /// 16 maybe validate sig?
|
||||
BitField<0, 1, u32> unknown; // 1 delete?
|
||||
BitField<1, 1, u32> read; // 2
|
||||
BitField<2, 1, u32> write; // 4
|
||||
BitField<3, 1, u32> create; // 8
|
||||
BitField<4, 1, u32> check; // 16 maybe validate sig?
|
||||
BitField<30, 1, u32> unk_flag;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user