Skip to content

Commit

Permalink
kernel: merge appInfo and appInfo2
Browse files Browse the repository at this point in the history
  • Loading branch information
DHrpcs3 committed Nov 27, 2024
1 parent 20303c9 commit eaf15a0
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 45 deletions.
16 changes: 2 additions & 14 deletions orbis-kernel/include/orbis/AppInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion orbis-kernel/include/orbis/KernelContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ enum class FwType : std::uint8_t {
Ps5,
};

struct RcAppInfo : RcBase, AppInfo2 {
struct RcAppInfo : RcBase, AppInfoEx {
orbis::uint32_t appState = 0;
};

Expand Down
3 changes: 1 addition & 2 deletions orbis-kernel/include/orbis/thread/Process.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ struct Process final {
ptr<void> processParam = nullptr;
uint64_t processParamSize = 0;
const ProcessOps *ops = nullptr;
AppInfo appInfo{};
AppInfo2 appInfo2{};
AppInfoEx appInfo{};
AuthInfo authInfo{};
kstring cwd;
kstring root = "/";
Expand Down
9 changes: 4 additions & 5 deletions orbis-kernel/src/sys/sys_sce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <sys/stat.h>

struct orbis::AppMountInfo {
AppInfo2 appInfo;
AppInfoEx appInfo;
uint64_t unk0;
uint64_t unk1;
uint64_t unk2;
Expand Down Expand Up @@ -1739,17 +1739,16 @@ orbis::SysResult orbis::sys_begin_app_mount(Thread *thread,

orbis::Ref appInfo = orbis::knew<RcAppInfo>();

AppInfo2 *appInfoData = appInfo.get();
AppInfoEx *appInfoData = appInfo.get();
auto handle = g_context.appInfos.insert(appInfo);
ORBIS_LOG_TODO(__FUNCTION__, handle);
thread->where();
if (handle == decltype(g_context.appInfos)::npos) {
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<uint32_t>(_info.result, handle);
Expand Down
42 changes: 19 additions & 23 deletions orbis-kernel/src/sys/sys_sysctl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,25 +292,20 @@ SysResult kern_sysctl(Thread *thread, ptr<sint> 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<AppInfo2>)old, process->appInfo2));
ORBIS_RET_ON_ERROR(uwrite(oldlenp, sizeof(AppInfo2)));
ORBIS_RET_ON_ERROR(uwrite((ptr<AppInfoEx>)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,
Expand All @@ -319,19 +314,20 @@ SysResult kern_sysctl(Thread *thread, ptr<sint> name, uint namelen,
process->appInfo.unk5, process->appInfo.unk6,
process->appInfo.unk7, process->appInfo.unk8);

ORBIS_RET_ON_ERROR(uwrite((ptr<AppInfo>)old, process->appInfo));
ORBIS_RET_ON_ERROR(
uwrite((ptr<AppInfo>)old, (AppInfo &)process->appInfo));
ORBIS_RET_ON_ERROR(uwrite(oldlenp, sizeof(AppInfo)));
} else {
return ErrorCode::INVAL;
}
}

if (new_) {
if (newlen == sizeof(AppInfo2)) {
auto result = uread(process->appInfo2, (ptr<AppInfo2>)new_);
if (newlen == sizeof(AppInfoEx)) {
auto result = uread(process->appInfo, (ptr<AppInfoEx>)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);
Expand All @@ -344,7 +340,7 @@ SysResult kern_sysctl(Thread *thread, ptr<sint> name, uint namelen,

return result;
} else if (newlen == sizeof(AppInfo)) {
auto result = uread(process->appInfo, (ptr<AppInfo>)new_);
auto result = uread((AppInfo &)process->appInfo, (ptr<AppInfo>)new_);
if (result == ErrorCode{}) {
auto &appInfo = process->appInfo;
ORBIS_LOG_ERROR("set AppInfo", appInfo.appId, appInfo.unk0,
Expand Down Expand Up @@ -428,7 +424,7 @@ SysResult kern_sysctl(Thread *thread, ptr<sint> name, uint namelen,

ORBIS_LOG_ERROR("1.14.65", name[3], oldlen);

if (oldlen < sizeof(AppInfo2)) {
if (oldlen < sizeof(AppInfoEx)) {
return ErrorCode::INVAL;
}

Expand All @@ -437,13 +433,13 @@ SysResult kern_sysctl(Thread *thread, ptr<sint> name, uint namelen,
appInfo->unk2, appInfo->unk3, appInfo->unk5,
appInfo->unk6, appInfo->unk7, appInfo->unk8);

if (auto errc = uwrite((ptr<AppInfo2>)old,
*static_cast<AppInfo2 *>(appInfo.get()));
if (auto errc = uwrite((ptr<AppInfoEx>)old,
*static_cast<AppInfoEx *>(appInfo.get()));
errc != ErrorCode{}) {
return errc;
}

if (auto errc = uwrite(oldlenp, sizeof(AppInfo2));
if (auto errc = uwrite(oldlenp, sizeof(AppInfoEx));
errc != ErrorCode{}) {
return errc;
}
Expand Down

0 comments on commit eaf15a0

Please sign in to comment.