Class DetourGenerator
Syntax
public static class DetourGenerator
Methods
Writes a detour on
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. |
Reads assembly from
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. |
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 |
Declaration
public static void Disassemble(ManualLogSource logSource, IntPtr memoryPtr, int size)
Parameters
Type | Name | Description |
---|---|---|
ManualLogSource |
logSource |
|
System.IntPtr |
memoryPtr |
|
System.Int32 |
size |
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[] |
Declaration
public static int GetDetourLength(Architecture arch)
Parameters
Type | Name | Description |
---|---|---|
System.Runtime.InteropServices.Architecture |
arch |
Returns
Type | Description |
---|---|
System.Int32 |