Table of Contents

Method CreateAlternateEntrypoint

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

CreateAlternateEntrypoint(nint, nint, int, out IDisposable?)

Creates an alternate entrypoint for the function at entrypointPc, ensuring that changes to the first minLength bytes of that function will not interfere with the alternate entrypoint.
nint CreateAlternateEntrypoint(nint entrypointPc, nint entrypointCode, int minLength, out IDisposable? handle)

Parameters

entrypointPc nint
The PC main entrypoint of the function to create an alternate entrypoint for.
entrypointCode nint
The address from which to actually read code. The code will be relocated as if it started at entrypointPc instead.
minLength int
The minimum number of bytes of code that should be safe to replace.
handle IDisposable
A handle to any memory allocations made for this alternate entrypoint.

Returns

nint
A pointer to the created alternate entry point.

Remarks

This method only guarantees that the alternate entrypoint will be valid as long as no more than minLength bytes of the original entrypoint are changed. While in practice more bytes may be safe, it is is not safe in general to write more bytes. There is currently not an API which is capable of expanding this space, which means that detours which use this to create an alternate entrypoint cannot be safely retargeted in general.