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

Function LinkAddressToGuestFunction

Source/Tools/LinuxEmulation/Thunks.cpp:412–421  ·  view source on GitHub ↗

* Instructs the Core to redirect calls to functions at the given * address to another function. The original callee address is passed * to the target function through an implicit argument stored in r11. * * For 32-bit the implicit argument is stored in the lower 32-bits of mm0. * * The primary use case of this is ensuring that host function pointers * returned from thunked API

Source from the content-addressed store, hash-verified

410 * returned from thunked APIs can safely be called by the guest.
411 */
412 void LinkAddressToGuestFunction(void* argsv) {
413 struct args_t {
414 uintptr_t original_callee;
415 uintptr_t target_addr; // Guest function to call when branching to original_callee
416 };
417
418 auto args = reinterpret_cast<args_t*>(argsv);
419 auto CTX = static_cast<FEXCore::Context::Context*>(ThreadObject->Thread->CTX);
420 CTX->AddThunkTrampolineIRHandler(args->original_callee, args->target_addr);
421 }
422
423 /**
424 * Guest-side helper to initiate creation of a host trampoline for

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected