From 10254a3c7e0880a09b5b2dafd22f16db3c09fb96 Mon Sep 17 00:00:00 2001 From: ParantezTech <12572227+par274@users.noreply.github.com> Date: Thu, 8 Oct 2026 23:44:40 +0300 Subject: [PATCH] [Cpu] Place the guest exception mcontext at the start of the context Co-authored-by: Sekai <140012992+SekaixX@users.noreply.github.com> --- src/SharpEmu.Core/Cpu/Native/DirectExecutionBackend.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/SharpEmu.Core/Cpu/Native/DirectExecutionBackend.cs b/src/SharpEmu.Core/Cpu/Native/DirectExecutionBackend.cs index 366fcdb..cc70e22 100644 --- a/src/SharpEmu.Core/Cpu/Native/DirectExecutionBackend.cs +++ b/src/SharpEmu.Core/Cpu/Native/DirectExecutionBackend.cs @@ -5386,11 +5386,7 @@ public sealed unsafe partial class DirectExecutionBackend : INativeCpuBackend, I BinaryPrimitives.WriteUInt64LittleEndian(bytes.AsSpan(offset, sizeof(ulong)), value); var hasContinuation = continuation.Rip >= 65536 && continuation.Rsp != 0; - // Orbis ucontext_t has a 0x10-byte signal mask and 0x30 bytes of - // private fields before its amd64 mcontext. These offsets match the - // platform ABI used by libScePs5Util and Unity's Boehm GC. Supplying a - // bare mcontext here makes the collector miss live register roots. - const int mcontext = 0x40; + const int mcontext = 0; Write64(mcontext + 0x08, hasContinuation ? continuation.Rdi : context[CpuRegister.Rdi]); Write64(mcontext + 0x10, hasContinuation ? continuation.Rsi : context[CpuRegister.Rsi]); Write64(mcontext + 0x18, hasContinuation ? continuation.Rdx : context[CpuRegister.Rdx]);