diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/hle/service/ptm/ptm.cpp | 12 | ||||
-rw-r--r-- | src/core/hle/service/ptm/ptm.h | 8 | ||||
-rw-r--r-- | src/core/hle/service/ptm/ptm_u.cpp | 2 | ||||
-rw-r--r-- | src/core/loader/loader.h | 1 | ||||
-rw-r--r-- | src/core/loader/ncch.cpp | 8 | ||||
-rw-r--r-- | src/core/loader/ncch.h | 36 |
6 files changed, 46 insertions, 21 deletions
diff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cpp index 2c7d49c9f..22c1093ff 100644 --- a/src/core/hle/service/ptm/ptm.cpp +++ b/src/core/hle/service/ptm/ptm.cpp @@ -68,6 +68,18 @@ void GetBatteryChargeState(Service::Interface* self) { LOG_WARNING(Service_PTM, "(STUBBED) called"); } +void GetTotalStepCount(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + // TODO: This function is only a stub, + // it returns 0 as the total step count + + cmd_buff[1] = RESULT_SUCCESS.raw; + cmd_buff[2] = 0; + + LOG_WARNING(Service_PTM, "(STUBBED) called"); +} + void IsLegacyPowerOff(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); diff --git a/src/core/hle/service/ptm/ptm.h b/src/core/hle/service/ptm/ptm.h index b690003cb..f2e76441f 100644 --- a/src/core/hle/service/ptm/ptm.h +++ b/src/core/hle/service/ptm/ptm.h @@ -72,6 +72,14 @@ void GetBatteryLevel(Interface* self); void GetBatteryChargeState(Interface* self); /** + * PTM::GetTotalStepCount service function + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 2 : Output of function, * = total step count + */ +void GetTotalStepCount(Interface* self); + +/** * PTM::IsLegacyPowerOff service function * Outputs: * 1: Result code, 0 on success, otherwise error code diff --git a/src/core/hle/service/ptm/ptm_u.cpp b/src/core/hle/service/ptm/ptm_u.cpp index 3f5e9c7c1..09dc38c3e 100644 --- a/src/core/hle/service/ptm/ptm_u.cpp +++ b/src/core/hle/service/ptm/ptm_u.cpp @@ -23,7 +23,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x00090000, nullptr, "GetPedometerState"}, {0x000A0042, nullptr, "GetStepHistoryEntry"}, {0x000B00C2, nullptr, "GetStepHistory"}, - {0x000C0000, nullptr, "GetTotalStepCount"}, + {0x000C0000, GetTotalStepCount, "GetTotalStepCount"}, {0x000D0040, nullptr, "SetPedometerRecordingMode"}, {0x000E0000, nullptr, "GetPedometerRecordingMode"}, {0x000F0084, nullptr, "GetStepHistoryAll"}, diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index 8de95dacf..a7f2715ba 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h @@ -71,6 +71,7 @@ enum class ResultStatus { ErrorNotUsed, ErrorAlreadyLoaded, ErrorMemoryAllocationFailed, + ErrorEncrypted, }; static inline u32 MakeMagic(char a, char b, char c, char d) { diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index 094d74100..68b3f546e 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp @@ -128,9 +128,8 @@ ResultStatus AppLoader_NCCH::LoadExec() { if (ResultStatus::Success == ReadCode(code)) { std::string process_name = Common::StringFromFixedZeroTerminatedBuffer( (const char*)exheader_header.codeset_info.name, 8); - u64 program_id = *reinterpret_cast<u64_le const*>(&ncch_header.program_id[0]); - SharedPtr<CodeSet> codeset = CodeSet::Create(process_name, program_id); + SharedPtr<CodeSet> codeset = CodeSet::Create(process_name, ncch_header.program_id); codeset->code.offset = 0; codeset->code.addr = exheader_header.codeset_info.text.address; @@ -266,6 +265,11 @@ ResultStatus AppLoader_NCCH::Load() { LOG_DEBUG(Loader, "Thread priority: 0x%X" , priority); LOG_DEBUG(Loader, "Resource limit category: %d" , resource_limit_category); + if (exheader_header.arm11_system_local_caps.program_id != ncch_header.program_id) { + LOG_ERROR(Loader, "ExHeader Program ID mismatch: the ROM is probably encrypted."); + return ResultStatus::ErrorEncrypted; + } + // Read ExeFS... exefs_offset = ncch_header.exefs_offset * kBlockSize; diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h index d875e4cf3..ca6772a78 100644 --- a/src/core/loader/ncch.h +++ b/src/core/loader/ncch.h @@ -17,31 +17,31 @@ struct NCCH_Header { u8 signature[0x100]; - u32 magic; - u32 content_size; + u32_le magic; + u32_le content_size; u8 partition_id[8]; - u16 maker_code; - u16 version; + u16_le maker_code; + u16_le version; u8 reserved_0[4]; - u8 program_id[8]; + u64_le program_id; u8 reserved_1[0x10]; u8 logo_region_hash[0x20]; u8 product_code[0x10]; u8 extended_header_hash[0x20]; - u32 extended_header_size; + u32_le extended_header_size; u8 reserved_2[4]; u8 flags[8]; - u32 plain_region_offset; - u32 plain_region_size; - u32 logo_region_offset; - u32 logo_region_size; - u32 exefs_offset; - u32 exefs_size; - u32 exefs_hash_region_size; + u32_le plain_region_offset; + u32_le plain_region_size; + u32_le logo_region_offset; + u32_le logo_region_size; + u32_le exefs_offset; + u32_le exefs_size; + u32_le exefs_hash_region_size; u8 reserved_3[4]; - u32 romfs_offset; - u32 romfs_size; - u32 romfs_hash_region_size; + u32_le romfs_offset; + u32_le romfs_size; + u32_le romfs_hash_region_size; u8 reserved_4[4]; u8 exefs_super_block_hash[0x20]; u8 romfs_super_block_hash[0x20]; @@ -109,8 +109,8 @@ struct ExHeader_StorageInfo { }; struct ExHeader_ARM11_SystemLocalCaps { - u8 program_id[8]; - u32 core_version; + u64_le program_id; + u32_le core_version; u8 reserved_flags[2]; union { u8 flags0; |