Revise FunctionHook
API to require function prototype information (.NET 9+)
#39
Labels
area: hooking
Issues related to the function hooking APIs.
area: samples
Issues related to the sample projects.
state: blocked
Issues that are blocked on some other issue or work.
Milestone
This is a very long term goal.
The idea is to require the user to somehow communicate the function prototype to the API. The hook gate implementation can then use that information to perform a proper call to the hook function instead of the return address hijacking we do now:
ruptura/src/memory/Code/FunctionHook.cs
Lines 221 to 226 in ae5f685
We would also be able to inject extra arguments in the call to the hook function, which might be useful in some scenarios.
There are two approaches we could take:
Type
parameter inFunctionHook.Create()
that must be a function pointer type.FunctionHook
to have a type parameterTFunction
that must be a function pointer type.The second approach is preferable as it would enable the
TargetCode
,HookCode
, andTrampolineCode
properties to be typed properly, cutting down on error-prone casts in user code. This would require both dotnet/runtime#13627 and dotnet/runtime#69273.The first approach would only require dotnet/runtime#69273 (which seems very likely to arrive in .NET 8), but it also doesn't get us the type safety that the second approach does.
We'll have to wait for .NET 8 and see how things look to determine what we'll do here.
The text was updated successfully, but these errors were encountered: