From 6ead0cc7b046a6b09a6e2c525f2aa7de9773e4bd Mon Sep 17 00:00:00 2001 From: ChendoChap <39858639+ChendoChap@users.noreply.github.com> Date: Sun, 3 Nov 2024 19:28:22 +0100 Subject: [PATCH 1/2] Update fself.cpp --- hen/src/fself.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/hen/src/fself.cpp b/hen/src/fself.cpp index b586687..5ec9842 100644 --- a/hen/src/fself.cpp +++ b/hen/src/fself.cpp @@ -41,15 +41,28 @@ extern "C" { static volatile int enableHook6 = 1; } +struct mtx { + uint8_t dontcare[0x18]; + volatile uintptr_t mtx_lock; +}; + SelfContext* getSelfContextByServiceId(uint32_t serviceId) { auto ctxTable = (SelfContext *) kdlsym(KERNEL_SYM_CTXTABLE); - + auto ctxStatus = (int*) kdlsym(KERNEL_SYM_CTXSTATUS); + auto ctxTableMtx = (mtx*) kdlsym(KERNEL_SYM_CTXTABLE_MTX); + auto __mtx_lock_flags = (void(*)(volatile uintptr_t*, int, const char*, int)) kdlsym(KERNEL_SYM_MTX_LOCK_FLAGS); + auto __mtx_unlock_flags = (void(*)(volatile uintptr_t*, int, const char*, int)) kdlsym(KERNEL_SYM_MTX_UNLOCK_FLAGS); + + __mtx_lock_flags(&ctxTableMtx->mtx_lock, 0, nullptr, 0); for(int i = 0; i < 4; i++) { + if(ctxStatus[i] != 3 && ctxStatus[i] != 4) { continue; } auto ctx = &ctxTable[i]; if(ctx->unk1C == serviceId) { + __mtx_unlock_flags(&ctxTableMtx->mtx_lock, 0, nullptr, 0); return ctx; } } + __mtx_unlock_flags(&ctxTableMtx->mtx_lock, 0, nullptr, 0); return nullptr; } From 153af1d50cb4fe1c347c0f9f5cbb8712586d6cbb Mon Sep 17 00:00:00 2001 From: ChendoChap <39858639+ChendoChap@users.noreply.github.com> Date: Sun, 3 Nov 2024 19:31:04 +0100 Subject: [PATCH 2/2] Update main.cpp preferably reset mirrors before playing with blocking sockets. --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 46f17aa..bb76cf2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -181,7 +181,7 @@ int main() SOCK_LOG("[+] Aft. hook is_development_mode = 0x%x\n", __sys_is_development_mode()); - run_self_server(9004); reset_mirrors(); + run_self_server(9004); return 0; }