Class JumpPatch
- Namespace
- SkyrimForge
- Assembly
- SkyrimForge.dll
public sealed class JumpPatch : CodePatch
- Inheritance
-
JumpPatch
- Inherited Members
Remarks
The jump occupies the first five expected bytes, and the rest of them become nops. The expected bytes therefore end on an instruction, and no branch elsewhere in the function lands inside them. Apply(params ReadOnlySpan<CodePatch>) detects a direct branch in the function part the exception directory lists, not a branch through a jump table or a register. The target begins an instruction where its module's exception directory lists the function containing it, and lies inside no recorded patch or hook past its first byte.
The target lies within a 32-bit displacement of the address, as the game's own code and memory from AllocateCode(nint, int) do. The entry point of a managed method usually does not, so a plugin redirecting game code to managed code uses IFunctionHooks. Code in allocated memory is complete before the jump reaching it is applied.
Constructors
JumpPatch(nint, BytePattern, nint)
Creates a patch replacing the expected bytes at address with a jump to target.
public JumpPatch(nint address, BytePattern expected, nint target)
Parameters
addressnintThe address of the first expected byte.
expectedBytePatternThe bytes the code at
addressmust match: the whole instructions replaced, at least five bytes.targetnintThe address the jump reaches.
Exceptions
- ArgumentOutOfRangeException
addressortargetis 0,expectedis shorter than five bytes, ortargetlies farther fromaddressthan a 32-bit displacement reaches.- ArgumentNullException
expectedisnull.
Properties
Target
The address the jump reaches.
public nint Target { get; }