From eaf15a016905ea520ee4e7c573f22b58b2101f92 Mon Sep 17 00:00:00 2001 From: DH Date: Wed, 27 Nov 2024 14:10:53 +0300 Subject: [PATCH] kernel: merge appInfo and appInfo2 --- orbis-kernel/include/orbis/AppInfo.hpp | 16 +------ orbis-kernel/include/orbis/KernelContext.hpp | 2 +- orbis-kernel/include/orbis/thread/Process.hpp | 3 +- orbis-kernel/src/sys/sys_sce.cpp | 9 ++-- orbis-kernel/src/sys/sys_sysctl.cpp | 42 +++++++++---------- 5 files changed, 27 insertions(+), 45 deletions(-) diff --git a/orbis-kernel/include/orbis/AppInfo.hpp b/orbis-kernel/include/orbis/AppInfo.hpp index 97423a6..31581ba 100644 --- a/orbis-kernel/include/orbis/AppInfo.hpp +++ b/orbis-kernel/include/orbis/AppInfo.hpp @@ -20,22 +20,10 @@ struct AppInfo { }; static_assert(sizeof(AppInfo) == 72); -struct AppInfo2 { - uint32_t appId; - uint32_t unk0; - uint32_t unk1; - uint32_t appType; - char titleId[10]; - uint16_t unk2; - uint32_t unk3; - slong unk4; - slong unk5; - slong unk6; - slong unk7; - slong unk8; +struct AppInfoEx : AppInfo { slong unk9; slong unk10; }; -static_assert(sizeof(AppInfo2) == 88); +static_assert(sizeof(AppInfoEx) == 88); } // namespace orbis diff --git a/orbis-kernel/include/orbis/KernelContext.hpp b/orbis-kernel/include/orbis/KernelContext.hpp index 86315d4..c7ec466 100644 --- a/orbis-kernel/include/orbis/KernelContext.hpp +++ b/orbis-kernel/include/orbis/KernelContext.hpp @@ -55,7 +55,7 @@ enum class FwType : std::uint8_t { Ps5, }; -struct RcAppInfo : RcBase, AppInfo2 { +struct RcAppInfo : RcBase, AppInfoEx { orbis::uint32_t appState = 0; }; diff --git a/orbis-kernel/include/orbis/thread/Process.hpp b/orbis-kernel/include/orbis/thread/Process.hpp index f3f1aeb..e42a16b 100644 --- a/orbis-kernel/include/orbis/thread/Process.hpp +++ b/orbis-kernel/include/orbis/thread/Process.hpp @@ -68,8 +68,7 @@ struct Process final { ptr processParam = nullptr; uint64_t processParamSize = 0; const ProcessOps *ops = nullptr; - AppInfo appInfo{}; - AppInfo2 appInfo2{}; + AppInfoEx appInfo{}; AuthInfo authInfo{}; kstring cwd; kstring root = "/"; diff --git a/orbis-kernel/src/sys/sys_sce.cpp b/orbis-kernel/src/sys/sys_sce.cpp index 03c2f42..028da63 100644 --- a/orbis-kernel/src/sys/sys_sce.cpp +++ b/orbis-kernel/src/sys/sys_sce.cpp @@ -20,7 +20,7 @@ #include struct orbis::AppMountInfo { - AppInfo2 appInfo; + AppInfoEx appInfo; uint64_t unk0; uint64_t unk1; uint64_t unk2; @@ -1739,7 +1739,7 @@ orbis::SysResult orbis::sys_begin_app_mount(Thread *thread, orbis::Ref appInfo = orbis::knew(); - AppInfo2 *appInfoData = appInfo.get(); + AppInfoEx *appInfoData = appInfo.get(); auto handle = g_context.appInfos.insert(appInfo); ORBIS_LOG_TODO(__FUNCTION__, handle); thread->where(); @@ -1747,9 +1747,8 @@ orbis::SysResult orbis::sys_begin_app_mount(Thread *thread, return ErrorCode::DOOFUS; } - std::memcpy(appInfoData, &_info, sizeof(AppInfo2)); - std::memcpy(&thread->tproc->appInfo2, &_info, sizeof(AppInfo2)); - thread->tproc->appInfo2.appId = handle; + std::memcpy(appInfoData, &_info, sizeof(AppInfoEx)); + std::memcpy(&thread->tproc->appInfo, &_info, sizeof(AppInfoEx)); appInfoData->appId = handle; return orbis::uwrite(_info.result, handle); diff --git a/orbis-kernel/src/sys/sys_sysctl.cpp b/orbis-kernel/src/sys/sys_sysctl.cpp index 8d37a41..dc13397 100644 --- a/orbis-kernel/src/sys/sys_sysctl.cpp +++ b/orbis-kernel/src/sys/sys_sysctl.cpp @@ -292,25 +292,20 @@ SysResult kern_sysctl(Thread *thread, ptr name, uint namelen, } } - ORBIS_LOG_ERROR("1.14.35", name[3]); - thread->where(); - if (old) { size_t oldlen; ORBIS_RET_ON_ERROR(uread(oldlen, oldlenp)); - ORBIS_LOG_ERROR("1.14.35", name[3], oldlen); - - if (oldlen == sizeof(AppInfo2)) { - ORBIS_LOG_ERROR("get AppInfo2", process->appInfo2.appId, - process->appInfo2.unk0, process->appInfo2.unk1, - process->appInfo2.appType, process->appInfo2.titleId, - process->appInfo2.unk2, process->appInfo2.unk3, - process->appInfo2.unk5, process->appInfo2.unk6, - process->appInfo2.unk7, process->appInfo2.unk8); + if (oldlen == sizeof(AppInfoEx)) { + ORBIS_LOG_ERROR("get AppInfoEx", process->appInfo.appId, + process->appInfo.unk0, process->appInfo.unk1, + process->appInfo.appType, process->appInfo.titleId, + process->appInfo.unk2, process->appInfo.unk3, + process->appInfo.unk5, process->appInfo.unk6, + process->appInfo.unk7, process->appInfo.unk8); - ORBIS_RET_ON_ERROR(uwrite((ptr)old, process->appInfo2)); - ORBIS_RET_ON_ERROR(uwrite(oldlenp, sizeof(AppInfo2))); + ORBIS_RET_ON_ERROR(uwrite((ptr)old, process->appInfo)); + ORBIS_RET_ON_ERROR(uwrite(oldlenp, sizeof(AppInfoEx))); } else if (oldlen == sizeof(AppInfo)) { ORBIS_LOG_ERROR("get AppInfo", process->appInfo.appId, process->appInfo.unk0, process->appInfo.unk1, @@ -319,7 +314,8 @@ SysResult kern_sysctl(Thread *thread, ptr name, uint namelen, process->appInfo.unk5, process->appInfo.unk6, process->appInfo.unk7, process->appInfo.unk8); - ORBIS_RET_ON_ERROR(uwrite((ptr)old, process->appInfo)); + ORBIS_RET_ON_ERROR( + uwrite((ptr)old, (AppInfo &)process->appInfo)); ORBIS_RET_ON_ERROR(uwrite(oldlenp, sizeof(AppInfo))); } else { return ErrorCode::INVAL; @@ -327,11 +323,11 @@ SysResult kern_sysctl(Thread *thread, ptr name, uint namelen, } if (new_) { - if (newlen == sizeof(AppInfo2)) { - auto result = uread(process->appInfo2, (ptr)new_); + if (newlen == sizeof(AppInfoEx)) { + auto result = uread(process->appInfo, (ptr)new_); if (result == ErrorCode{}) { auto &appInfo = process->appInfo; - ORBIS_LOG_ERROR("set AppInfo2", appInfo.appId, appInfo.unk0, + ORBIS_LOG_ERROR("set AppInfoEx", appInfo.appId, appInfo.unk0, appInfo.unk1, appInfo.appType, appInfo.titleId, appInfo.unk2, appInfo.unk3, appInfo.unk5, appInfo.unk6, appInfo.unk7, appInfo.unk8); @@ -344,7 +340,7 @@ SysResult kern_sysctl(Thread *thread, ptr name, uint namelen, return result; } else if (newlen == sizeof(AppInfo)) { - auto result = uread(process->appInfo, (ptr)new_); + auto result = uread((AppInfo &)process->appInfo, (ptr)new_); if (result == ErrorCode{}) { auto &appInfo = process->appInfo; ORBIS_LOG_ERROR("set AppInfo", appInfo.appId, appInfo.unk0, @@ -428,7 +424,7 @@ SysResult kern_sysctl(Thread *thread, ptr name, uint namelen, ORBIS_LOG_ERROR("1.14.65", name[3], oldlen); - if (oldlen < sizeof(AppInfo2)) { + if (oldlen < sizeof(AppInfoEx)) { return ErrorCode::INVAL; } @@ -437,13 +433,13 @@ SysResult kern_sysctl(Thread *thread, ptr name, uint namelen, appInfo->unk2, appInfo->unk3, appInfo->unk5, appInfo->unk6, appInfo->unk7, appInfo->unk8); - if (auto errc = uwrite((ptr)old, - *static_cast(appInfo.get())); + if (auto errc = uwrite((ptr)old, + *static_cast(appInfo.get())); errc != ErrorCode{}) { return errc; } - if (auto errc = uwrite(oldlenp, sizeof(AppInfo2)); + if (auto errc = uwrite(oldlenp, sizeof(AppInfoEx)); errc != ErrorCode{}) { return errc; }