Table of Contents

Method ComputeRetargetInfo

Namespace
MonoMod.Core.Platforms
Assembly
MonoMod.Core.dll

ComputeRetargetInfo(NativeDetourInfo, nint, int)

Computes a NativeDetourInfo which can be used to retarget detour to instead jump to target.
NativeDetourInfo ComputeRetargetInfo(NativeDetourInfo detour, nint target, int maxSizeHint = -1)

Parameters

detour NativeDetourInfo
The detour to retarget.
target nint
The new target of the detour.
maxSizeHint int
The maximum amount of readable/writable memory at the detour site, or -1. This is to be used as a hint, and may be ignored.

Returns

NativeDetourInfo
The computed NativeDetourInfo.

Remarks

The typical calling sequence is ComputeRetargetInfo(NativeDetourInfo, nint, int), allocate a buffer, GetRetargetBytes(NativeDetourInfo, NativeDetourInfo, Span<byte>, out IDisposable?, out bool, out bool), then if (and ONLY if) needsRepatch is true, PatchData(PatchTargetKind, nint, ReadOnlySpan<byte>, Span<byte>) to patch the data in. Then, if disposeOldAlloc is true, dispose the allocations associated with the original detour.

Usually, callers should use ChangeTarget(nint) instead.

See Also