Skip to content

Commit

Permalink
kernel: replace title ID offset references with p_titleid field
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonid Pavel committed Jun 11, 2023
1 parent 198c609 commit bb9cde1
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions kernel/src/OrbisOS/Utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ int Utilities::CreatePOSIXThread(struct proc* p, void* entrypoint) {

size_t s_Size = 0;
int s_Ret = 0;
char* s_TitleId = (char*)((uint64_t)p + 0x390);
char* s_TitleId = p->p_titleid;

WriteLog(LL_Info, "[%s] Creating POSIX Thread (Entrypoint: %p) ...", s_TitleId, entrypoint);

Expand Down Expand Up @@ -567,7 +567,7 @@ int Utilities::LoadPRXModule(struct proc* p, const char* prx_path)

size_t s_Size = 0;
int s_Ret = 0;
char* s_TitleId = (char*)((uint64_t)p + 0x390);
char* s_TitleId = p->p_titleid;

WriteLog(LL_Info, "[%s] Loading PRX (%s) over POSIX ...", s_TitleId, prx_path);

Expand Down
2 changes: 1 addition & 1 deletion kernel/src/Plugins/FakePkg/FakePkgManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ void FakePkgManager::ProcessStartEvent(void *arg, struct ::proc *p)
if (!p)
return;

char* s_TitleId = (char*)((uint64_t)p + 0x390);
char* s_TitleId = p->p_titleid;
if (strncmp(s_TitleId, "NPXS20000", 9) == 0)
ShellCorePatch();

Expand Down
2 changes: 1 addition & 1 deletion kernel/src/Plugins/MorpheusEnabler/MorpheusEnabler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void MorpheusEnabler::ProcessStartEvent(void *arg, struct ::proc *p)
if (!p)
return;

char* s_TitleId = (char*)((uint64_t)p + 0x390);
char* s_TitleId = p->p_titleid;
if (strncmp(s_TitleId, "NPXS20000", 9) == 0)
DoPatch();

Expand Down
2 changes: 1 addition & 1 deletion kernel/src/Plugins/RemotePlayEnabler/RemotePlayEnabler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void RemotePlayEnabler::ProcessStartEvent(void *arg, struct ::proc *p)
if (!p)
return;

char* s_TitleId = (char*)((uint64_t)p + 0x390);
char* s_TitleId = p->p_titleid;
if (strncmp(s_TitleId, "NPXS20001", 9) == 0)
ShellUIPatch();

Expand Down
15 changes: 7 additions & 8 deletions kernel/src/Plugins/Substitute/Substitute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ void Substitute::CleanupProcessHook(struct proc* p) {
if (!p)
return;

char* s_TitleId = (char*)((uint64_t)p + 0x390);
char* s_TitleId = p->p_titleid;
WriteLog(LL_Info, "Cleaning up hook for %s", s_TitleId);


Expand Down Expand Up @@ -799,8 +799,7 @@ void* Substitute::FindOriginalAddress(struct proc* p, const char* name, int32_t
if (p == nullptr)
return nullptr;

// TODO: Fix this structure within proc
char* s_TitleId = (char*)((uint64_t)p + 0x390);
char* s_TitleId = p->p_titleid;
void* s_Address = nullptr;

WriteLog(LL_Info, "TitleId: (%s).", s_TitleId);
Expand Down Expand Up @@ -869,7 +868,7 @@ uint64_t Substitute::FindJmpslotAddress(struct proc* p, const char* module_name,
return 0;
}

char* s_TitleId = (char*)((uint64_t)p + 0x390);
char* s_TitleId = p->p_titleid;

// Get the nids of the function
char nids[0xD] = { 0 };
Expand Down Expand Up @@ -1000,7 +999,7 @@ void Substitute::LoadAllPrx(struct thread* td, const char* folder_path)
return;
}

char* s_TitleId = (char*)((uint64_t)td->td_proc + 0x390);
char* s_TitleId = td->td_proc->p_titleid;

// Opening substitute folder
auto s_DirectoryHandle = kopen_t(folder_path, O_RDONLY | O_DIRECTORY, 0777, td);
Expand Down Expand Up @@ -1059,7 +1058,7 @@ bool Substitute::OnProcessExecEnd(struct proc *p)
auto vn_fullpath = (int(*)(struct thread *td, struct vnode *vp, char **retbuf, char **freebuf))kdlsym(vn_fullpath);

struct thread* s_ProcessThread = FIRST_THREAD_IN_PROC(p);
char* s_TitleId = (char*)((uint64_t)p + 0x390);
char* s_TitleId = p->p_titleid;

// Check if it's a valid process
if ( !s_TitleId || s_TitleId[0] == 0 )
Expand Down Expand Up @@ -1173,7 +1172,7 @@ bool Substitute::OnProcessExit(struct proc *p) {

// Get process information
struct thread* s_ProcessThread = FIRST_THREAD_IN_PROC(p);
char* s_TitleId = (char*)((uint64_t)p + 0x390);
char* s_TitleId = p->p_titleid;

Substitute* substitute = GetPlugin();

Expand Down Expand Up @@ -1277,7 +1276,7 @@ int Substitute::Sys_dynlib_dlsym_hook(struct thread* td, struct dynlib_dlsym_arg
return ret;
}

char* s_TitleId = (char*)((uint64_t)td->td_proc + 0x390);
char* s_TitleId = td->td_proc->p_titleid;

// Check if it's a valid process
if ( !s_TitleId || s_TitleId[0] == 0) {
Expand Down
4 changes: 2 additions & 2 deletions kernel/src/Plugins/Substitute2/Substitute2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bool Substitute2::OnProcessExecEnd(struct proc* p_Process)
return true;

// Check the title id's against the supported
const char* s_TitleId = &p_Process->p_unk348[0x58];
const char* s_TitleId = p_Process->p_titleid;
if (s_TitleId == nullptr)
return false;

Expand All @@ -50,4 +50,4 @@ bool Substitute2::OnProcessExit(struct proc* p_Process)
bool Substitute2::GetTitlePath(SubstituteFlags p_Flags, const char* p_TitleId, const char*& p_OutPath)
{
return false;
}
}

0 comments on commit bb9cde1

Please sign in to comment.