IOS: Move ES return codes
This keeps all of the return codes in the same place and exposed publicly (as they are not internal to ES). I have also added proper IOSC error codes and renamed some codes for more consistency. (Unix ones have an E prefix, others do not.)
This commit is contained in:
parent
bcb1729dc9
commit
68cd8fc910
|
@ -19,30 +19,57 @@ namespace HLE
|
|||
{
|
||||
enum ReturnCode : s32
|
||||
{
|
||||
IPC_SUCCESS = 0, // Success
|
||||
IPC_EACCES = -1, // Permission denied
|
||||
IPC_EEXIST = -2, // File exists
|
||||
IPC_EINVAL = -4, // Invalid argument or fd
|
||||
IPC_ENOENT = -6, // File not found
|
||||
IPC_EQUEUEFULL = -8, // Queue full
|
||||
IPC_EIO = -12, // ECC error
|
||||
IPC_ENOMEM = -22, // Alloc failed during request
|
||||
FS_EINVAL = -101, // Invalid path
|
||||
FS_EACCESS = -102, // Permission denied
|
||||
FS_ECORRUPT = -103, // Corrupted NAND
|
||||
FS_EEXIST = -105, // File exists
|
||||
FS_ENOENT = -106, // No such file or directory
|
||||
FS_ENFILE = -107, // Too many fds open
|
||||
FS_EFBIG = -108, // Max block count reached?
|
||||
FS_EFDEXHAUSTED = -109, // Too many fds open
|
||||
FS_ENAMELEN = -110, // Pathname is too long
|
||||
FS_EFDOPEN = -111, // FD is already open
|
||||
FS_EIO = -114, // ECC error
|
||||
FS_ENOTEMPTY = -115, // Directory not empty
|
||||
FS_EDIRDEPTH = -116, // Max directory depth exceeded
|
||||
FS_EBUSY = -118, // Resource busy
|
||||
IPC_EESEXHAUSTED = -1016, // Max of 2 ES handles exceeded
|
||||
USB_ECANCELED = -7022, // USB OH0 insertion hook cancelled
|
||||
IPC_SUCCESS = 0, // Success
|
||||
IPC_EACCES = -1, // Permission denied
|
||||
IPC_EEXIST = -2, // File exists
|
||||
IPC_EINVAL = -4, // Invalid argument or fd
|
||||
IPC_ENOENT = -6, // File not found
|
||||
IPC_EQUEUEFULL = -8, // Queue full
|
||||
IPC_EIO = -12, // ECC error
|
||||
IPC_ENOMEM = -22, // Alloc failed during request
|
||||
FS_EINVAL = -101, // Invalid path
|
||||
FS_EACCESS = -102, // Permission denied
|
||||
FS_ECORRUPT = -103, // Corrupted NAND
|
||||
FS_EEXIST = -105, // File exists
|
||||
FS_ENOENT = -106, // No such file or directory
|
||||
FS_ENFILE = -107, // Too many fds open
|
||||
FS_EFBIG = -108, // Max block count reached?
|
||||
FS_EFDEXHAUSTED = -109, // Too many fds open
|
||||
FS_ENAMELEN = -110, // Pathname is too long
|
||||
FS_EFDOPEN = -111, // FD is already open
|
||||
FS_EIO = -114, // ECC error
|
||||
FS_ENOTEMPTY = -115, // Directory not empty
|
||||
FS_EDIRDEPTH = -116, // Max directory depth exceeded
|
||||
FS_EBUSY = -118, // Resource busy
|
||||
ES_SHORT_READ = -1009, // Short read
|
||||
ES_EIO = -1010, // Write failure
|
||||
ES_FD_EXHAUSTED = -1016, // Max of 3 ES handles exceeded
|
||||
ES_EINVAL = -1017, // Invalid argument
|
||||
ES_DEVICE_ID_MISMATCH = -1018,
|
||||
ES_HASH_MISMATCH = -1022, // Decrypted content hash doesn't match with the hash from the TMD
|
||||
ES_ENOMEM = -1024, // Alloc failed during request
|
||||
ES_EACCES = -1026, // Incorrect access rights (according to TMD)
|
||||
ES_INVALID_TMD_SIGNATURE_TYPE = -1027,
|
||||
ES_NO_TICKET = -1028,
|
||||
ES_INVALID_TICKET = -1029,
|
||||
IOSC_EACCES = -2000,
|
||||
IOSC_EEXIST = -2001,
|
||||
IOSC_EINVAL = -2002,
|
||||
IOSC_EMAX = -2003,
|
||||
IOSC_ENOENT = -2004,
|
||||
IOSC_INVALID_OBJTYPE = -2005,
|
||||
IOSC_INVALID_RNG = -2006,
|
||||
IOSC_INVALID_FLAG = -2007,
|
||||
IOSC_INVALID_FORMAT = -2008,
|
||||
IOSC_INVALID_VERSION = -2009,
|
||||
IOSC_INVALID_SIGNER = -2010,
|
||||
IOSC_FAIL_CHECKVALUE = -2011,
|
||||
IOSC_FAIL_INTERNAL = -2012,
|
||||
IOSC_FAIL_ALLOC = -2013,
|
||||
IOSC_INVALID_SIZE = -2014,
|
||||
IOSC_INVALID_ADDR = -2015,
|
||||
IOSC_INVALID_ALIGN = -2016,
|
||||
USB_ECANCELED = -7022, // USB OH0 insertion hook cancelled
|
||||
};
|
||||
|
||||
struct Request
|
||||
|
|
|
@ -132,7 +132,7 @@ void ES::LoadWAD(const std::string& _rContentFile)
|
|||
IPCCommandResult ES::GetTitleDirectory(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 1))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);
|
||||
|
||||
|
@ -146,10 +146,10 @@ IPCCommandResult ES::GetTitleDirectory(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::GetTitleID(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(0, 1))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
if (!s_title_context.active)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
const u64 title_id = s_title_context.tmd.GetTitleId();
|
||||
Memory::Write_U64(title_id, request.io_vectors[0].address);
|
||||
|
@ -161,7 +161,7 @@ IPCCommandResult ES::GetTitleID(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::SetUID(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 0))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
// TODO: fs permissions based on this
|
||||
u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);
|
||||
|
@ -420,7 +420,7 @@ IPCCommandResult ES::IOCtlV(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::GetConsumption(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 2))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
// This is at least what crediar's ES module does
|
||||
Memory::Write_U32(0, request.io_vectors[1].address);
|
||||
|
@ -431,7 +431,7 @@ IPCCommandResult ES::GetConsumption(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::Launch(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(2, 0))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);
|
||||
u32 view = Memory::Read_U32(request.in_vectors[1].address);
|
||||
|
@ -446,7 +446,7 @@ IPCCommandResult ES::Launch(const IOCtlVRequest& request)
|
|||
// IOS replies to the request through the mailbox on failure, and acks if the launch succeeds.
|
||||
// Note: Launch will potentially reset the whole IOS state -- including this ES instance.
|
||||
if (!LaunchTitle(TitleID))
|
||||
return GetDefaultReply(ES_INVALID_TMD);
|
||||
return GetDefaultReply(FS_ENOENT);
|
||||
|
||||
// Generate a "reply" to the IPC command. ES_LAUNCH is unique because it
|
||||
// involves restarting IOS; IOS generates two acknowledgements in a row.
|
||||
|
@ -459,15 +459,15 @@ IPCCommandResult ES::Launch(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::LaunchBC(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(0, 0))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
// Here, IOS checks the clock speed and prevents ioctlv 0x25 from being used in GC mode.
|
||||
// An alternative way to do this is to check whether the current active IOS is MIOS.
|
||||
if (GetVersion() == 0x101)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
if (!LaunchTitle(0x0000000100000100))
|
||||
return GetDefaultReply(ES_INVALID_TMD);
|
||||
return GetDefaultReply(FS_ENOENT);
|
||||
|
||||
EnqueueCommandAcknowledgement(request.address, 0);
|
||||
return GetNoReply();
|
||||
|
@ -496,10 +496,10 @@ s32 ES::DIVerify(const IOS::ES::TMDReader& tmd, const IOS::ES::TicketReader& tic
|
|||
INFO_LOG(IOS_ES, "ES_DIVerify: Title context changed: (none)");
|
||||
|
||||
if (!tmd.IsValid() || !ticket.IsValid())
|
||||
return ES_PARAMETER_SIZE_OR_ALIGNMENT;
|
||||
return ES_EINVAL;
|
||||
|
||||
if (tmd.GetTitleId() != ticket.GetTitleId())
|
||||
return ES_PARAMETER_SIZE_OR_ALIGNMENT;
|
||||
return ES_EINVAL;
|
||||
|
||||
std::string tmd_path = Common::GetTMDFileName(tmd.GetTitleId(), Common::FROM_SESSION_ROOT);
|
||||
|
||||
|
|
|
@ -124,23 +124,6 @@ private:
|
|||
IOCTL_ES_CHECKKOREAREGION = 0x45,
|
||||
};
|
||||
|
||||
enum EErrorCodes
|
||||
{
|
||||
ES_INVALID_TMD = -106, // or access denied
|
||||
ES_READ_LESS_DATA_THAN_EXPECTED = -1009,
|
||||
ES_WRITE_FAILURE = -1010,
|
||||
ES_PARAMETER_SIZE_OR_ALIGNMENT = -1017,
|
||||
ES_DEVICE_ID_MISMATCH = -1020,
|
||||
ES_HASH_DOESNT_MATCH = -1022,
|
||||
ES_MEM_ALLOC_FAILED = -1024,
|
||||
ES_INCORRECT_ACCESS_RIGHT = -1026,
|
||||
ES_NO_TICKET_INSTALLED = -1028,
|
||||
ES_INSTALLED_TICKET_INVALID = -1029,
|
||||
ES_INVALID_PARAMETR = -2008,
|
||||
ES_SIGNATURE_CHECK_FAILED = -2011,
|
||||
ES_HASH_SIZE_WRONG = -2014, // HASH !=20
|
||||
};
|
||||
|
||||
struct OpenedContent
|
||||
{
|
||||
u64 m_title_id;
|
||||
|
|
|
@ -55,7 +55,7 @@ void ES::DecryptContent(u32 key_index, u8* iv, u8* input, u32 size, u8* new_iv,
|
|||
IPCCommandResult ES::GetConsoleID(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(0, 1))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
const EcWii& ec = EcWii::GetInstance();
|
||||
INFO_LOG(IOS_ES, "IOCTL_ES_GETDEVICEID %08X", ec.GetNGID());
|
||||
|
@ -66,7 +66,7 @@ IPCCommandResult ES::GetConsoleID(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::Encrypt(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(3, 2))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
u32 keyIndex = Memory::Read_U32(request.in_vectors[0].address);
|
||||
u8* IV = Memory::GetPointer(request.in_vectors[1].address);
|
||||
|
@ -88,7 +88,7 @@ IPCCommandResult ES::Encrypt(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::Decrypt(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(3, 2))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
u32 keyIndex = Memory::Read_U32(request.in_vectors[0].address);
|
||||
u8* IV = Memory::GetPointer(request.in_vectors[1].address);
|
||||
|
@ -107,20 +107,20 @@ IPCCommandResult ES::Decrypt(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::CheckKoreaRegion(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(0, 0))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
// note by DacoTaco : name is unknown, I just tried to name it SOMETHING.
|
||||
// IOS70 has this to let system menu 4.2 check if the console is region changed. it returns
|
||||
// -1017
|
||||
// if the IOS didn't find the Korean keys and 0 if it does. 0 leads to a error 003
|
||||
INFO_LOG(IOS_ES, "IOCTL_ES_CHECKKOREAREGION: Title checked for Korean keys.");
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
}
|
||||
|
||||
IPCCommandResult ES::GetDeviceCertificate(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(0, 1) || request.io_vectors[0].size != 0x180)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
INFO_LOG(IOS_ES, "IOCTL_ES_GETDEVICECERT");
|
||||
u8* destination = Memory::GetPointer(request.io_vectors[0].address);
|
||||
|
@ -133,7 +133,7 @@ IPCCommandResult ES::GetDeviceCertificate(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::Sign(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 2))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
INFO_LOG(IOS_ES, "IOCTL_ES_SIGN");
|
||||
u8* ap_cert_out = Memory::GetPointer(request.io_vectors[1].address);
|
||||
|
@ -142,7 +142,7 @@ IPCCommandResult ES::Sign(const IOCtlVRequest& request)
|
|||
u8* sig_out = Memory::GetPointer(request.io_vectors[0].address);
|
||||
|
||||
if (!GetTitleContext().active)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
const EcWii& ec = EcWii::GetInstance();
|
||||
MakeAPSigAndCert(sig_out, ap_cert_out, GetTitleContext().tmd.GetTitleId(), data, data_size,
|
||||
|
|
|
@ -51,7 +51,7 @@ u32 ES::OpenTitleContent(u32 CFD, u64 TitleID, u16 Index)
|
|||
IPCCommandResult ES::OpenTitleContent(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(3, 0))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);
|
||||
u32 Index = Memory::Read_U32(request.in_vectors[2].address);
|
||||
|
@ -67,11 +67,11 @@ IPCCommandResult ES::OpenTitleContent(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::OpenContent(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 0))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
u32 Index = Memory::Read_U32(request.in_vectors[0].address);
|
||||
|
||||
if (!GetTitleContext().active)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
s32 CFD = OpenTitleContent(m_AccessIdentID++, GetTitleContext().tmd.GetTitleId(), Index);
|
||||
INFO_LOG(IOS_ES, "IOCTL_ES_OPENCONTENT: Index %i -> got CFD %x", Index, CFD);
|
||||
|
@ -82,7 +82,7 @@ IPCCommandResult ES::OpenContent(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::ReadContent(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 1))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
u32 CFD = Memory::Read_U32(request.in_vectors[0].address);
|
||||
u32 Size = request.io_vectors[0].size;
|
||||
|
@ -134,7 +134,7 @@ IPCCommandResult ES::ReadContent(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::CloseContent(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 0))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
u32 CFD = Memory::Read_U32(request.in_vectors[0].address);
|
||||
|
||||
|
@ -163,7 +163,7 @@ IPCCommandResult ES::CloseContent(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::SeekContent(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(3, 0))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
u32 CFD = Memory::Read_U32(request.in_vectors[0].address);
|
||||
u32 Addr = Memory::Read_U32(request.in_vectors[1].address);
|
||||
|
|
|
@ -30,7 +30,7 @@ IPCCommandResult ES::GetStoredContentsCount(const IOS::ES::TMDReader& tmd,
|
|||
const IOCtlVRequest& request)
|
||||
{
|
||||
if (request.io_vectors[0].size != sizeof(u32) || !tmd.IsValid())
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
const u16 num_contents = static_cast<u16>(IOS::ES::GetStoredContentsFromTMD(tmd).size());
|
||||
Memory::Write_U32(num_contents, request.io_vectors[0].address);
|
||||
|
@ -45,12 +45,12 @@ IPCCommandResult ES::GetStoredContentsCount(const IOS::ES::TMDReader& tmd,
|
|||
IPCCommandResult ES::GetStoredContents(const IOS::ES::TMDReader& tmd, const IOCtlVRequest& request)
|
||||
{
|
||||
if (!tmd.IsValid())
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
if (request.in_vectors[1].size != sizeof(u32) ||
|
||||
request.io_vectors[0].size != Memory::Read_U32(request.in_vectors[1].address) * sizeof(u32))
|
||||
{
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
}
|
||||
|
||||
const auto contents = IOS::ES::GetStoredContentsFromTMD(tmd);
|
||||
|
@ -64,7 +64,7 @@ IPCCommandResult ES::GetStoredContents(const IOS::ES::TMDReader& tmd, const IOCt
|
|||
IPCCommandResult ES::GetStoredContentsCount(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 1) || request.in_vectors[0].size != sizeof(u64))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
const u64 title_id = Memory::Read_U64(request.in_vectors[0].address);
|
||||
const IOS::ES::TMDReader tmd = IOS::ES::FindInstalledTMD(title_id);
|
||||
|
@ -76,7 +76,7 @@ IPCCommandResult ES::GetStoredContentsCount(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::GetStoredContents(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(2, 1) || request.in_vectors[0].size != sizeof(u64))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
const u64 title_id = Memory::Read_U64(request.in_vectors[0].address);
|
||||
const IOS::ES::TMDReader tmd = IOS::ES::FindInstalledTMD(title_id);
|
||||
|
@ -88,7 +88,7 @@ IPCCommandResult ES::GetStoredContents(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::GetTMDStoredContentsCount(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 1))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
std::vector<u8> tmd_bytes(request.in_vectors[0].size);
|
||||
Memory::CopyFromEmu(tmd_bytes.data(), request.in_vectors[0].address, tmd_bytes.size());
|
||||
|
@ -98,7 +98,7 @@ IPCCommandResult ES::GetTMDStoredContentsCount(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::GetTMDStoredContents(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(2, 1))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
std::vector<u8> tmd_bytes(request.in_vectors[0].size);
|
||||
Memory::CopyFromEmu(tmd_bytes.data(), request.in_vectors[0].address, tmd_bytes.size());
|
||||
|
@ -108,7 +108,7 @@ IPCCommandResult ES::GetTMDStoredContents(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::GetTitleCount(const std::vector<u64>& titles, const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(0, 1) || request.io_vectors[0].size != 4)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
Memory::Write_U32(static_cast<u32>(titles.size()), request.io_vectors[0].address);
|
||||
|
||||
|
@ -118,7 +118,7 @@ IPCCommandResult ES::GetTitleCount(const std::vector<u64>& titles, const IOCtlVR
|
|||
IPCCommandResult ES::GetTitles(const std::vector<u64>& titles, const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 1))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
const size_t max_count = Memory::Read_U32(request.in_vectors[0].address);
|
||||
for (size_t i = 0; i < std::min(max_count, titles.size()); i++)
|
||||
|
@ -144,7 +144,7 @@ IPCCommandResult ES::GetTitles(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::GetStoredTMDSize(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 1))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
const u64 title_id = Memory::Read_U64(request.in_vectors[0].address);
|
||||
const IOS::ES::TMDReader tmd = IOS::ES::FindInstalledTMD(title_id);
|
||||
|
@ -162,7 +162,7 @@ IPCCommandResult ES::GetStoredTMDSize(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::GetStoredTMD(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(2, 1))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
const u64 title_id = Memory::Read_U64(request.in_vectors[0].address);
|
||||
const IOS::ES::TMDReader tmd = IOS::ES::FindInstalledTMD(title_id);
|
||||
|
@ -174,7 +174,7 @@ IPCCommandResult ES::GetStoredTMD(const IOCtlVRequest& request)
|
|||
|
||||
const std::vector<u8> raw_tmd = tmd.GetRawTMD();
|
||||
if (raw_tmd.size() != request.io_vectors[0].size)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
Memory::CopyToEmu(request.io_vectors[0].address, raw_tmd.data(), raw_tmd.size());
|
||||
|
||||
|
@ -197,7 +197,7 @@ IPCCommandResult ES::GetOwnedTitles(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::GetBoot2Version(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(0, 1))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
INFO_LOG(IOS_ES, "IOCTL_ES_GETBOOT2VERSION");
|
||||
|
||||
|
|
|
@ -32,14 +32,14 @@ namespace Device
|
|||
IPCCommandResult ES::AddTicket(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(3, 0))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
std::vector<u8> bytes(request.in_vectors[0].size);
|
||||
Memory::CopyFromEmu(bytes.data(), request.in_vectors[0].address, request.in_vectors[0].size);
|
||||
|
||||
IOS::ES::TicketReader ticket{std::move(bytes)};
|
||||
if (!ticket.IsValid())
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
const u32 ticket_device_id = ticket.GetDeviceId();
|
||||
const u32 device_id = EcWii::GetInstance().GetNGID();
|
||||
|
@ -60,7 +60,7 @@ IPCCommandResult ES::AddTicket(const IOCtlVRequest& request)
|
|||
}
|
||||
|
||||
if (!DiscIO::AddTicket(ticket))
|
||||
return GetDefaultReply(ES_WRITE_FAILURE);
|
||||
return GetDefaultReply(ES_EIO);
|
||||
|
||||
INFO_LOG(IOS_ES, "AddTicket: Imported ticket for title %016" PRIx64, ticket.GetTitleId());
|
||||
return GetDefaultReply(IPC_SUCCESS);
|
||||
|
@ -69,7 +69,7 @@ IPCCommandResult ES::AddTicket(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::AddTMD(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 0))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
std::vector<u8> tmd(request.in_vectors[0].size);
|
||||
Memory::CopyFromEmu(tmd.data(), request.in_vectors[0].address, request.in_vectors[0].size);
|
||||
|
@ -77,8 +77,9 @@ IPCCommandResult ES::AddTMD(const IOCtlVRequest& request)
|
|||
// Ioctlv 0x2b writes the TMD to /tmp/title.tmd (for imports) and doesn't seem to write it
|
||||
// to either /import or /title. So here we simply have to set the import TMD.
|
||||
m_addtitle_tmd.SetBytes(std::move(tmd));
|
||||
// TODO: validate TMDs and return the proper error code (-1027) if the signature type is invalid.
|
||||
if (!m_addtitle_tmd.IsValid())
|
||||
return GetDefaultReply(ES_INVALID_TMD);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
if (!IOS::ES::InitImport(m_addtitle_tmd.GetTitleId()))
|
||||
return GetDefaultReply(FS_EIO);
|
||||
|
@ -89,7 +90,7 @@ IPCCommandResult ES::AddTMD(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::AddTitleStart(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(4, 0))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
INFO_LOG(IOS_ES, "IOCTL_ES_ADDTITLESTART");
|
||||
std::vector<u8> tmd(request.in_vectors[0].size);
|
||||
|
@ -99,7 +100,7 @@ IPCCommandResult ES::AddTitleStart(const IOCtlVRequest& request)
|
|||
if (!m_addtitle_tmd.IsValid())
|
||||
{
|
||||
ERROR_LOG(IOS_ES, "Invalid TMD while adding title (size = %zd)", tmd.size());
|
||||
return GetDefaultReply(ES_INVALID_TMD);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
}
|
||||
|
||||
// Finish a previous import (if it exists).
|
||||
|
@ -118,7 +119,7 @@ IPCCommandResult ES::AddTitleStart(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::AddContentStart(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(2, 0))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
u64 title_id = Memory::Read_U64(request.in_vectors[0].address);
|
||||
u32 content_id = Memory::Read_U32(request.in_vectors[1].address);
|
||||
|
@ -127,7 +128,7 @@ IPCCommandResult ES::AddContentStart(const IOCtlVRequest& request)
|
|||
{
|
||||
ERROR_LOG(IOS_ES, "Trying to add content when we haven't finished adding "
|
||||
"another content. Unsupported.");
|
||||
return GetDefaultReply(ES_WRITE_FAILURE);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
}
|
||||
m_addtitle_content_id = content_id;
|
||||
|
||||
|
@ -138,7 +139,7 @@ IPCCommandResult ES::AddContentStart(const IOCtlVRequest& request)
|
|||
title_id, m_addtitle_content_id);
|
||||
|
||||
if (!m_addtitle_tmd.IsValid())
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
if (title_id != m_addtitle_tmd.GetTitleId())
|
||||
{
|
||||
|
@ -158,7 +159,7 @@ IPCCommandResult ES::AddContentStart(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::AddContentData(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(2, 0))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
u32 content_fd = Memory::Read_U32(request.in_vectors[0].address);
|
||||
INFO_LOG(IOS_ES, "IOCTL_ES_ADDCONTENTDATA: content fd %08x, "
|
||||
|
@ -186,22 +187,22 @@ static std::string GetImportContentPath(u64 title_id, u32 content_id)
|
|||
IPCCommandResult ES::AddContentFinish(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 0))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
if (m_addtitle_content_id == 0xFFFFFFFF)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
u32 content_fd = Memory::Read_U32(request.in_vectors[0].address);
|
||||
INFO_LOG(IOS_ES, "IOCTL_ES_ADDCONTENTFINISH: content fd %08x", content_fd);
|
||||
|
||||
if (!m_addtitle_tmd.IsValid())
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
// Try to find the title key from a pre-installed ticket.
|
||||
IOS::ES::TicketReader ticket = DiscIO::FindSignedTicket(m_addtitle_tmd.GetTitleId());
|
||||
if (!ticket.IsValid())
|
||||
{
|
||||
return GetDefaultReply(ES_NO_TICKET_INSTALLED);
|
||||
return GetDefaultReply(ES_NO_TICKET);
|
||||
}
|
||||
|
||||
mbedtls_aes_context aes_ctx;
|
||||
|
@ -212,7 +213,7 @@ IPCCommandResult ES::AddContentFinish(const IOCtlVRequest& request)
|
|||
IOS::ES::Content content_info;
|
||||
if (!m_addtitle_tmd.FindContentById(m_addtitle_content_id, &content_info))
|
||||
{
|
||||
return GetDefaultReply(ES_INVALID_TMD);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
}
|
||||
u8 iv[16] = {0};
|
||||
iv[0] = (content_info.index >> 8) & 0xFF;
|
||||
|
@ -223,7 +224,7 @@ IPCCommandResult ES::AddContentFinish(const IOCtlVRequest& request)
|
|||
if (!CheckIfContentHashMatches(decrypted_data, content_info))
|
||||
{
|
||||
ERROR_LOG(IOS_ES, "AddContentFinish: Hash for content %08x doesn't match", content_info.id);
|
||||
return GetDefaultReply(ES_HASH_DOESNT_MATCH);
|
||||
return GetDefaultReply(ES_HASH_MISMATCH);
|
||||
}
|
||||
|
||||
std::string content_path;
|
||||
|
@ -247,14 +248,14 @@ IPCCommandResult ES::AddContentFinish(const IOCtlVRequest& request)
|
|||
if (!file.WriteBytes(decrypted_data.data(), content_info.size))
|
||||
{
|
||||
ERROR_LOG(IOS_ES, "AddContentFinish: Failed to write to %s", temp_path.c_str());
|
||||
return GetDefaultReply(ES_WRITE_FAILURE);
|
||||
return GetDefaultReply(ES_EIO);
|
||||
}
|
||||
}
|
||||
|
||||
if (!File::Rename(temp_path, content_path))
|
||||
{
|
||||
ERROR_LOG(IOS_ES, "AddContentFinish: Failed to move content to %s", content_path.c_str());
|
||||
return GetDefaultReply(ES_WRITE_FAILURE);
|
||||
return GetDefaultReply(ES_EIO);
|
||||
}
|
||||
|
||||
m_addtitle_content_id = 0xFFFFFFFF;
|
||||
|
@ -264,10 +265,10 @@ IPCCommandResult ES::AddContentFinish(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::AddTitleFinish(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(0, 0) || !m_addtitle_tmd.IsValid())
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
if (!WriteImportTMD(m_addtitle_tmd))
|
||||
return GetDefaultReply(ES_WRITE_FAILURE);
|
||||
return GetDefaultReply(ES_EIO);
|
||||
|
||||
if (!FinishImport(m_addtitle_tmd))
|
||||
return GetDefaultReply(FS_EIO);
|
||||
|
@ -280,7 +281,7 @@ IPCCommandResult ES::AddTitleFinish(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::AddTitleCancel(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(0, 0) || !m_addtitle_tmd.IsValid())
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
const IOS::ES::TMDReader original_tmd = IOS::ES::FindInstalledTMD(m_addtitle_tmd.GetTitleId());
|
||||
if (!original_tmd.IsValid())
|
||||
|
@ -306,12 +307,12 @@ static bool CanDeleteTitle(u64 title_id)
|
|||
IPCCommandResult ES::DeleteTitle(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 0) || request.in_vectors[0].size != 8)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
const u64 title_id = Memory::Read_U64(request.in_vectors[0].address);
|
||||
|
||||
if (!CanDeleteTitle(title_id))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
const std::string title_dir =
|
||||
StringFromFormat("%s/title/%08x/%08x/", RootUserPath(Common::FROM_SESSION_ROOT).c_str(),
|
||||
|
@ -334,14 +335,14 @@ IPCCommandResult ES::DeleteTitle(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::DeleteTicket(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 0))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);
|
||||
INFO_LOG(IOS_ES, "IOCTL_ES_DELETETICKET: title: %08x/%08x", (u32)(TitleID >> 32), (u32)TitleID);
|
||||
|
||||
// Presumably return -1017 when delete fails
|
||||
if (!File::Delete(Common::GetTicketFileName(TitleID, Common::FROM_SESSION_ROOT)))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
return GetDefaultReply(IPC_SUCCESS);
|
||||
}
|
||||
|
@ -349,7 +350,7 @@ IPCCommandResult ES::DeleteTicket(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::DeleteTitleContent(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 0))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);
|
||||
INFO_LOG(IOS_ES, "IOCTL_ES_DELETETITLECONTENT: title: %08x/%08x", (u32)(TitleID >> 32),
|
||||
|
@ -357,7 +358,7 @@ IPCCommandResult ES::DeleteTitleContent(const IOCtlVRequest& request)
|
|||
|
||||
// Presumably return -1017 when title not installed TODO verify
|
||||
if (!DiscIO::CNANDContentManager::Access().RemoveTitle(TitleID, Common::FROM_SESSION_ROOT))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
return GetDefaultReply(IPC_SUCCESS);
|
||||
}
|
||||
|
@ -365,11 +366,11 @@ IPCCommandResult ES::DeleteTitleContent(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::ExportTitleInit(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 1) || request.in_vectors[0].size != 8)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
// No concurrent title import/export is allowed.
|
||||
if (m_export_title_context.valid)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
const auto tmd = IOS::ES::FindInstalledTMD(Memory::Read_U64(request.in_vectors[0].address));
|
||||
if (!tmd.IsValid())
|
||||
|
@ -379,15 +380,15 @@ IPCCommandResult ES::ExportTitleInit(const IOCtlVRequest& request)
|
|||
|
||||
const auto ticket = DiscIO::FindSignedTicket(m_export_title_context.tmd.GetTitleId());
|
||||
if (!ticket.IsValid())
|
||||
return GetDefaultReply(ES_NO_TICKET_INSTALLED);
|
||||
return GetDefaultReply(ES_NO_TICKET);
|
||||
if (ticket.GetTitleId() != m_export_title_context.tmd.GetTitleId())
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
m_export_title_context.title_key = ticket.GetTitleKey();
|
||||
|
||||
const auto& raw_tmd = m_export_title_context.tmd.GetRawTMD();
|
||||
if (request.io_vectors[0].size != raw_tmd.size())
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
Memory::CopyToEmu(request.io_vectors[0].address, raw_tmd.data(), raw_tmd.size());
|
||||
|
||||
|
@ -399,7 +400,7 @@ IPCCommandResult ES::ExportContentBegin(const IOCtlVRequest& request)
|
|||
{
|
||||
if (!request.HasNumberOfValidVectors(2, 0) || request.in_vectors[0].size != 8 ||
|
||||
request.in_vectors[1].size != 4)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
const u64 title_id = Memory::Read_U64(request.in_vectors[0].address);
|
||||
const u32 content_id = Memory::Read_U32(request.in_vectors[1].address);
|
||||
|
@ -407,7 +408,7 @@ IPCCommandResult ES::ExportContentBegin(const IOCtlVRequest& request)
|
|||
if (!m_export_title_context.valid || m_export_title_context.tmd.GetTitleId() != title_id)
|
||||
{
|
||||
ERROR_LOG(IOS_ES, "Tried to use ExportContentBegin with an invalid title export context.");
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
}
|
||||
|
||||
const auto& content_loader = AccessContentDevice(title_id);
|
||||
|
@ -416,7 +417,7 @@ IPCCommandResult ES::ExportContentBegin(const IOCtlVRequest& request)
|
|||
|
||||
const auto* content = content_loader.GetContentByID(content_id);
|
||||
if (!content)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
OpenedContent entry;
|
||||
entry.m_position = 0;
|
||||
|
@ -443,7 +444,7 @@ IPCCommandResult ES::ExportContentData(const IOCtlVRequest& request)
|
|||
if (!request.HasNumberOfValidVectors(1, 1) || request.in_vectors[0].size != 4 ||
|
||||
request.io_vectors[0].size == 0)
|
||||
{
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
}
|
||||
|
||||
const u32 content_id = Memory::Read_U32(request.in_vectors[0].address);
|
||||
|
@ -453,7 +454,7 @@ IPCCommandResult ES::ExportContentData(const IOCtlVRequest& request)
|
|||
if (!m_export_title_context.valid || iterator == m_export_title_context.contents.end() ||
|
||||
iterator->second.content.m_position >= iterator->second.content.m_content.size)
|
||||
{
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
}
|
||||
|
||||
auto& metadata = iterator->second.content;
|
||||
|
@ -468,8 +469,8 @@ IPCCommandResult ES::ExportContentData(const IOCtlVRequest& request)
|
|||
|
||||
if (!content->m_Data->GetRange(metadata.m_position, length, buffer.data()))
|
||||
{
|
||||
ERROR_LOG(IOS_ES, "ExportContentData: ES_READ_LESS_DATA_THAN_EXPECTED");
|
||||
return GetDefaultReply(ES_READ_LESS_DATA_THAN_EXPECTED);
|
||||
ERROR_LOG(IOS_ES, "ExportContentData: ES_SHORT_READ");
|
||||
return GetDefaultReply(ES_SHORT_READ);
|
||||
}
|
||||
|
||||
// IOS aligns the buffer to 32 bytes. Since we also need to align it to 16 bytes,
|
||||
|
@ -485,7 +486,7 @@ IPCCommandResult ES::ExportContentData(const IOCtlVRequest& request)
|
|||
{
|
||||
// XXX: proper error code when IOSC_Encrypt fails.
|
||||
ERROR_LOG(IOS_ES, "ExportContentData: Failed to encrypt content.");
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
}
|
||||
|
||||
Memory::CopyToEmu(request.io_vectors[0].address, output.data(), output.size());
|
||||
|
@ -496,7 +497,7 @@ IPCCommandResult ES::ExportContentData(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::ExportContentEnd(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 0) || request.in_vectors[0].size != 4)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
const u32 content_id = Memory::Read_U32(request.in_vectors[0].address);
|
||||
|
||||
|
@ -504,7 +505,7 @@ IPCCommandResult ES::ExportContentEnd(const IOCtlVRequest& request)
|
|||
if (!m_export_title_context.valid || iterator == m_export_title_context.contents.end() ||
|
||||
iterator->second.content.m_position != iterator->second.content.m_content.size)
|
||||
{
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
}
|
||||
|
||||
// XXX: Check the content hash, as IOS does?
|
||||
|
@ -519,7 +520,7 @@ IPCCommandResult ES::ExportContentEnd(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::ExportTitleDone(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!m_export_title_context.valid)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
m_export_title_context.valid = false;
|
||||
return GetDefaultReply(IPC_SUCCESS);
|
||||
|
|
|
@ -38,7 +38,7 @@ static bool ShouldReturnFakeViewsForIOSes(u64 title_id, const TitleContext& cont
|
|||
IPCCommandResult ES::GetTicketViewCount(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 1))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);
|
||||
|
||||
|
@ -61,7 +61,7 @@ IPCCommandResult ES::GetTicketViewCount(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::GetTicketViews(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(2, 1))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);
|
||||
u32 maxViews = Memory::Read_U32(request.in_vectors[1].address);
|
||||
|
@ -93,7 +93,7 @@ IPCCommandResult ES::GetTicketViews(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::GetTMDViewSize(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 1))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);
|
||||
|
||||
|
@ -112,7 +112,7 @@ IPCCommandResult ES::GetTMDViewSize(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::GetTMDViews(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(2, 1))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);
|
||||
u32 MaxCount = Memory::Read_U32(request.in_vectors[1].address);
|
||||
|
@ -124,7 +124,7 @@ IPCCommandResult ES::GetTMDViews(const IOCtlVRequest& request)
|
|||
|
||||
const std::vector<u8> raw_view = tmd.GetRawView();
|
||||
if (raw_view.size() != request.io_vectors[0].size)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
Memory::CopyToEmu(request.io_vectors[0].address, raw_view.data(), raw_view.size());
|
||||
|
||||
|
@ -135,14 +135,14 @@ IPCCommandResult ES::GetTMDViews(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::DIGetTMDViewSize(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(1, 1))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
// Sanity check the TMD size.
|
||||
if (request.in_vectors[0].size >= 4 * 1024 * 1024)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
if (request.io_vectors[0].size != sizeof(u32))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
const bool has_tmd = request.in_vectors[0].size != 0;
|
||||
size_t tmd_view_size = 0;
|
||||
|
@ -156,7 +156,7 @@ IPCCommandResult ES::DIGetTMDViewSize(const IOCtlVRequest& request)
|
|||
// Yes, this returns -1017, not ES_INVALID_TMD.
|
||||
// IOS simply checks whether the TMD has all required content entries.
|
||||
if (!tmd.IsValid())
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
tmd_view_size = tmd.GetRawView().size();
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ IPCCommandResult ES::DIGetTMDViewSize(const IOCtlVRequest& request)
|
|||
{
|
||||
// If no TMD was passed in and no title is active, IOS returns -1017.
|
||||
if (!GetTitleContext().active)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
tmd_view_size = GetTitleContext().tmd.GetRawView().size();
|
||||
}
|
||||
|
@ -176,17 +176,17 @@ IPCCommandResult ES::DIGetTMDViewSize(const IOCtlVRequest& request)
|
|||
IPCCommandResult ES::DIGetTMDView(const IOCtlVRequest& request)
|
||||
{
|
||||
if (!request.HasNumberOfValidVectors(2, 1))
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
// Sanity check the TMD size.
|
||||
if (request.in_vectors[0].size >= 4 * 1024 * 1024)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
// Check whether the TMD view size is consistent.
|
||||
if (request.in_vectors[1].size != sizeof(u32) ||
|
||||
Memory::Read_U32(request.in_vectors[1].address) != request.io_vectors[0].size)
|
||||
{
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
}
|
||||
|
||||
const bool has_tmd = request.in_vectors[0].size != 0;
|
||||
|
@ -199,7 +199,7 @@ IPCCommandResult ES::DIGetTMDView(const IOCtlVRequest& request)
|
|||
const IOS::ES::TMDReader tmd{std::move(tmd_bytes)};
|
||||
|
||||
if (!tmd.IsValid())
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
tmd_view = tmd.GetRawView();
|
||||
}
|
||||
|
@ -207,13 +207,13 @@ IPCCommandResult ES::DIGetTMDView(const IOCtlVRequest& request)
|
|||
{
|
||||
// If no TMD was passed in and no title is active, IOS returns -1017.
|
||||
if (!GetTitleContext().active)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
tmd_view = GetTitleContext().tmd.GetRawView();
|
||||
}
|
||||
|
||||
if (tmd_view.size() != request.io_vectors[0].size)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
Memory::CopyToEmu(request.io_vectors[0].address, tmd_view.data(), tmd_view.size());
|
||||
return GetDefaultReply(IPC_SUCCESS);
|
||||
|
@ -224,14 +224,14 @@ IPCCommandResult ES::DIGetTicketView(const IOCtlVRequest& request)
|
|||
if (!request.HasNumberOfValidVectors(1, 1) ||
|
||||
request.io_vectors[0].size != sizeof(IOS::ES::TicketView))
|
||||
{
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
}
|
||||
|
||||
const bool has_ticket_vector = request.in_vectors[0].size == 0x2A4;
|
||||
|
||||
// This ioctlv takes either a signed ticket or no ticket, in which case the ticket size must be 0.
|
||||
if (!has_ticket_vector && request.in_vectors[0].size != 0)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
std::vector<u8> view;
|
||||
|
||||
|
@ -240,7 +240,7 @@ IPCCommandResult ES::DIGetTicketView(const IOCtlVRequest& request)
|
|||
if (!has_ticket_vector)
|
||||
{
|
||||
if (!GetTitleContext().active)
|
||||
return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT);
|
||||
return GetDefaultReply(ES_EINVAL);
|
||||
|
||||
view = GetTitleContext().ticket.GetRawTicketView(0);
|
||||
}
|
||||
|
|
|
@ -895,7 +895,7 @@ static s32 OpenDevice(const OpenRequest& request)
|
|||
{
|
||||
device = GetUnusedESDevice();
|
||||
if (!device)
|
||||
return IPC_EESEXHAUSTED;
|
||||
return ES_FD_EXHAUSTED;
|
||||
}
|
||||
else if (request.path.find("/dev/usb/oh0/") == 0 && !GetDeviceByName(request.path))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue