Method CreateAlternateEntrypoint
CreateAlternateEntrypoint(nint, int, out IDisposable?)
Creates an alternate entrypoint for the function at
entrypoint
, ensuring that changes to the first minLength
bytes of that function will not interfere with the alternate entrypoint.nint CreateAlternateEntrypoint(nint entrypoint, int minLength, out IDisposable? handle)
Parameters
entrypoint
nint- The main entrypoint of the function to create an alternate entrypoint for.
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.