MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / SyncThreadContext

Function SyncThreadContext

Source/Windows/ARM64EC/Module.cpp:619–631  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

617} // namespace Exception
618
619extern "C" void SyncThreadContext(CONTEXT* Context) {
620 ProcessPendingCrossProcessEmulatorWork();
621 auto* Thread = GetCPUArea().ThreadState();
622 // All other EFlags bits are lost when converting to/from an ARM64EC context, so merge them in from the current JIT state.
623 // This is advisable over dropping their values as thread suspend/resume uses this function, and that can happen at any point in guest code.
624 static constexpr uint32_t ECValidEFlagsMask {(1U << FEXCore::X86State::RFLAG_OF_RAW_LOC) | (1U << FEXCore::X86State::RFLAG_CF_RAW_LOC) |
625 (1U << FEXCore::X86State::RFLAG_ZF_RAW_LOC) | (1U << FEXCore::X86State::RFLAG_SF_RAW_LOC) |
626 (1U << FEXCore::X86State::RFLAG_TF_RAW_LOC)};
627
628 uint32_t StateEFlags = CTX->ReconstructCompactedEFLAGS(Thread, false, nullptr, 0);
629 Context->EFlags = (Context->EFlags & ECValidEFlagsMask) | (StateEFlags & ~ECValidEFlagsMask);
630 Exception::LoadStateFromECContext(Thread, *Context);
631}
632
633NTSTATUS ProcessInit() {
634 InitSyscalls();

Callers

nothing calls this directly

Calls 3

GetCPUAreaFunction · 0.85
LoadStateFromECContextFunction · 0.85

Tested by

no test coverage detected