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.
| 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. |
| 256 | void 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 | |
| 272 | void LoadImageVolatileMetadata(fextl::set<uint64_t>& VolatileInstructions, FEXCore::IntervalList<uint64_t>& VolatileValidRanges, |
| 273 | HMODULE Module, IMAGE_NT_HEADERS* Nt, uint64_t Address, uint64_t EndAddress) { |
no test coverage detected