Skip to content
Concord

Class RoutingDetourBackend

Namespace
Concord.Detour
Assembly
Concord.Detour.dll

A detour backend that decides, per target, whether Concord installs its own detour or hands its injections to a foreign patch host. Two libraries cannot both own one entry point, so a target another patcher has already claimed goes to the host instead, and Concord's injections ride along inside it. When the host can notify Concord before it rebuilds a method, a target Concord already detoured is promoted onto the host rather than silently losing its injections.

public sealed class RoutingDetourBackend : IDetourBackend, IForeignPatchObserver
Inheritance
RoutingDetourBackend
Implements
Inherited Members

Constructors

RoutingDetourBackend(IDetourBackend, Action<string>)

Initializes a new instance of the RoutingDetourBackend class.

public RoutingDetourBackend(IDetourBackend inner, Action<string> log)

Parameters

inner IDetourBackend

The backend used for targets Concord detours itself.

log Action<string>

Writes coexistence messages to the host game's log.

Properties

NotifierInstalled

Whether the host's notifier hook is installed. When false, late contention is only detectable by polling and is not recoverable.

public bool NotifierInstalled { get; }

Property Value

bool

RouteEverything

Routes every target through the host once one is active, not only contested ones.

public bool RouteEverything { get; set; }

Property Value

bool

Methods

ActivateHost(IForeignPatchHost)

Attaches the foreign patch host and tries to install its notifier hook. Only the first call takes effect.

public void ActivateHost(IForeignPatchHost host)

Parameters

host IForeignPatchHost

The host to route contested targets through.

Apply(MethodBase, MethodInfo)

Redirects calls from a target method to its wrapper.

public IDetourHandle Apply(MethodBase original, MethodInfo replacement)

Parameters

original MethodBase

The method to redirect.

replacement MethodInfo

The wrapper to execute instead.

Returns

IDetourHandle

A handle that reports detour state and restores the original method when disposed.

ApplyComposed(MethodBase, IReadOnlyList<Injection>)

Installs or replaces the single detour for target, composing one wrapper from every currently-live injection on that target plus added. Disposing the returned handle removes the injections it owns and recomposes (or removes) the target's detour.

public IDetourHandle ApplyComposed(MethodBase target, IReadOnlyList<Injection> added)

Parameters

target MethodBase

The method to redirect.

added IReadOnlyList<Injection>

The injections this call contributes to the target's composed wrapper.

Returns

IDetourHandle

A handle that reports detour state and removes only the injections it owns when disposed.

ContestedLostTargets()

Lists every target whose promotion to the host failed, so its Concord injections are not running.

public IReadOnlyCollection<MethodBase> ContestedLostTargets()

Returns

IReadOnlyCollection<MethodBase>

A snapshot of the lost targets.

GetRoute(MethodBase)

Reports how a target's detour is currently owned.

public RouteState GetRoute(MethodBase target)

Parameters

target MethodBase

The method to inspect.

Returns

RouteState

The target's route state, Unpinned when undecided.

OnForeignPatchPending(MethodBase, object)

Called just before the host rebuilds target, while the host holds its own lock. Implementations must not throw: an exception here escapes into the foreign library and breaks an unrelated caller's patch.

public void OnForeignPatchPending(MethodBase target, object hostPatchState)

Parameters

target MethodBase

The method the host is about to rebuild.

hostPatchState object

The host's own patch record for this rebuild, opaque to Concord. Concord must contribute through this object rather than by calling back into the host: the host applies and stores this record after the rebuild returns, so anything registered by a nested call is overwritten.

RawPinnedTargets()

Lists every target Concord currently owns with its own detour.

public IReadOnlyCollection<MethodBase> RawPinnedTargets()

Returns

IReadOnlyCollection<MethodBase>

A snapshot of the raw-detoured targets.