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

Function InitSyscalls

Source/Windows/ARM64EC/Module.cpp:256–270  ·  view source on GitHub ↗

Syscall thunks may have been patched before FEX has loaded, the default call checker installed by ntdll into FEX will try to invoke the JIT when calling such patched syscalls but this obviously doesn't work before FEX is initalised. This function parses ntdll and sets up a custom call checker to prevent this, as such it must avoid using any syscall thunks itself.

Source from the content-addressed store, hash-verified

254// This function parses ntdll and sets up a custom call checker to prevent this, as such it must avoid using any syscall
255// thunks itself.
256void InitSyscalls() {
257 // The ntdll exports called by GetModuleHandle/GetProcAddress aren't known to be patched before JIT init by any current
258 // software so are safe to call, but if that changes the loader structures in the PEB could be parsed manually.
259 const auto NtDll = GetModuleHandle("ntdll.dll");
260 NtDllBase = reinterpret_cast<uintptr_t>(NtDll);
261
262 const auto WineSyscallDispatcherPtr = reinterpret_cast<void**>(GetProcAddress(NtDll, "__wine_syscall_dispatcher"));
263 if (WineSyscallDispatcherPtr) {
264 WineSyscallDispatcher = *WineSyscallDispatcherPtr;
265 ParseWineSyscallNumbers(NtDll);
266 }
267
268 FillNtDllLUTs(NtDll);
269 PatchCallChecker();
270}
271
272void LoadImageVolatileMetadata(fextl::set<uint64_t>& VolatileInstructions, FEXCore::IntervalList<uint64_t>& VolatileValidRanges,
273 HMODULE Module, IMAGE_NT_HEADERS* Nt, uint64_t Address, uint64_t EndAddress) {

Callers 1

ProcessInitFunction · 0.85

Calls 3

ParseWineSyscallNumbersFunction · 0.85
FillNtDllLUTsFunction · 0.85
PatchCallCheckerFunction · 0.85

Tested by

no test coverage detected