Interface IForeignPatchHost
A foreign patching library that Concord can share a method with. When another library already owns a target's entry point, Concord hands its injections to the host instead of installing a second detour, because two detours cannot both control one entry point.
public interface IForeignPatchHost
Methods
ApplyToRouted(MethodBase, IReadOnlyList<Injection>)
Adds more injections to a target the host has already taken over.
IDetourHandle ApplyToRouted(MethodBase target, IReadOnlyList<Injection> added)
Parameters
targetMethodBaseThe routed method.
addedIReadOnlyList<Injection>The injections to add.
Returns
- IDetourHandle
A handle that removes only these injections when disposed.
EnterHostLock()
Takes the host's own patching lock, so Concord can establish one global lock order and avoid deadlocking against a host rebuild running on another thread. Reentrant on the same thread.
IDisposable? EnterHostLock()
Returns
- IDisposable
A scope that releases the lock when disposed, or null when the host has no reachable lock.
ForeignOwners(MethodBase)
Lists the identifiers of foreign patch owners on a target, ignoring Concord's own.
IReadOnlyList<string> ForeignOwners(MethodBase target)
Parameters
targetMethodBaseThe method to inspect.
Returns
- IReadOnlyList<string>
The foreign owner identifiers, empty when none.
RouteInto(MethodBase, IReadOnlyList<Injection>, object)
Hands injections to the host by contributing to a rebuild that is already in flight, rather than starting a new one. Used during promotion, where the host is mid-rebuild and will discard anything registered by a nested call.
ForeignRouteResult RouteInto(MethodBase target, IReadOnlyList<Injection> added, object hostPatchState)
Parameters
targetMethodBaseThe method being rebuilt.
addedIReadOnlyList<Injection>The injections Concord contributes.
hostPatchStateobjectThe host's patch record for the in-flight rebuild.
Returns
- ForeignRouteResult
Routed when the host accepted the contribution, otherwise the reason it did not.
TryInstallNotifier(IForeignPatchObserver, IDetourBackend)
Hooks the host so it notifies observer before it rebuilds any method.
Without this, Concord only learns about a foreign patch by polling after the fact.
bool TryInstallNotifier(IForeignPatchObserver observer, IDetourBackend rawBackend)
Parameters
observerIForeignPatchObserverThe observer to notify.
rawBackendIDetourBackendThe plain backend to install the hook with. This must not be the routing backend: routing the foreign library's own internals through the foreign library is circular.
Returns
- bool
True when the hook installed; false leaves Concord on poll-based detection.
TryRoute(MethodBase, IReadOnlyList<Injection>, bool)
Asks the host whether it needs to take over target, and hands over the
injections when it does.
ForeignRouteResult TryRoute(MethodBase target, IReadOnlyList<Injection> added, bool forceRoute)
Parameters
targetMethodBaseThe method Concord wants to patch.
addedIReadOnlyList<Injection>The injections Concord contributes to the target.
forceRouteboolRoute even when no foreign patcher has claimed the target.
Returns
- ForeignRouteResult
Whether the target was routed, left alone, or refused.
ValidateRoute(MethodBase, IReadOnlyList<Injection>)
Reports whether the host could take over a target, without changing anything. Used before a live promotion, so a refusal never has to unwind a detour that was already removed.
string? ValidateRoute(MethodBase target, IReadOnlyList<Injection> added)
Parameters
targetMethodBaseThe method to test.
addedIReadOnlyList<Injection>The injections that would be handed over.
Returns
- string
Null when the target is routable, otherwise the reason it is not.