Class JumpPatch
- Namespace
- SkyrimForge.Hooks
- Assembly
- SkyrimForge.dll
public sealed class JumpPatch : CodePatch
- Inheritance
-
JumpPatch
- Inherited Members
Remarks
The jump occupies the first five expected bytes, and the rest become nops. The expected bytes must end on an instruction, and no branch elsewhere in the function may land inside them. The target must begin an instruction, and must not lie inside a recorded patch or hook past its first byte.
The entry point of a managed method is usually beyond a 32-bit displacement, so redirect game code to managed code through IFunctionHooks. Memory from AllocateCode(nint, int) is within reach. Finish writing code there before applying the jump.
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; }