Class DetourGenerator

Inheritance
System.Object DetourGenerator
Inherited Members
System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone() System.Object.ReferenceEquals(System.Object, System.Object) System.Object.ToString()
Namespace: BepInEx.IL2CPP
Assembly: BepInEx.IL2CPP.dll
Syntax
public static class DetourGenerator

Methods

ApplyDetour(IntPtr, IntPtr, Architecture, Int32)

Writes a detour on to redirect to .

Declaration
public static void ApplyDetour(IntPtr functionPtr, IntPtr detourPtr, Architecture architecture, int minimumLength = 0)
Parameters
Type Name Description
System.IntPtr functionPtr

The pointer to the function to apply the detour to.

System.IntPtr detourPtr

The pointer to the function to redirect to.

System.Runtime.InteropServices.Architecture architecture

The architecture of the current platform.

System.Int32 minimumLength

The minimum amount of length that the detour should consume. If the generated redirect is smaller than this, the remaining space is padded with NOPs.

CreateTrampolineFromFunction(Byte[], IntPtr, IntPtr, Int32, Architecture, out Int32, out Int32)

Reads assembly from (at least bytes), and writes it to plus a jmp to continue execution.

Declaration
public static void CreateTrampolineFromFunction(byte[] instructionBuffer, IntPtr functionPtr, IntPtr trampolinePtr, int minimumTrampolineLength, Architecture arch, out int trampolineLength, out int jmpLength)
Parameters
Type Name Description
System.Byte[] instructionBuffer

The buffer to copy assembly from.

System.IntPtr functionPtr

The pointer to the function to copy assembly from.

System.IntPtr trampolinePtr

The pointer to write the trampoline assembly to.

System.Int32 minimumTrampolineLength

Copies at least this many bytes of assembly from .

System.Runtime.InteropServices.Architecture arch

The architecture of the current platform.

System.Int32 trampolineLength

Returns the total length of the trampoline, in bytes.

System.Int32 jmpLength

Returns the length of the jmp at the end of the trampoline, in bytes.

CreateTrampolineFromFunction(IntPtr, out Int32, out Int32)

Declaration
public static IntPtr CreateTrampolineFromFunction(IntPtr originalFuncPointer, out int trampolineLength, out int jmpLength)
Parameters
Type Name Description
System.IntPtr originalFuncPointer
System.Int32 trampolineLength
System.Int32 jmpLength
Returns
Type Description
System.IntPtr

Disassemble(ManualLogSource, IntPtr, Int32)

Declaration
public static void Disassemble(ManualLogSource logSource, IntPtr memoryPtr, int size)
Parameters
Type Name Description
ManualLogSource logSource
System.IntPtr memoryPtr
System.Int32 size

GenerateAbsoluteJump(IntPtr, IntPtr, Architecture)

Declaration
public static byte[] GenerateAbsoluteJump(IntPtr targetAddress, IntPtr currentAddress, Architecture arch)
Parameters
Type Name Description
System.IntPtr targetAddress
System.IntPtr currentAddress
System.Runtime.InteropServices.Architecture arch
Returns
Type Description
System.Byte[]

GetDetourLength(Architecture)

Declaration
public static int GetDetourLength(Architecture arch)
Parameters
Type Name Description
System.Runtime.InteropServices.Architecture arch
Returns
Type Description
System.Int32