Reloaded.Hooks icon indicating copy to clipboard operation
Reloaded.Hooks copied to clipboard

Using hooks from a native AOT library

Open valters-tomsons opened this issue 8 months ago • 5 comments

Description

I'm trying to use Reloaded.Hooks in a project with Ahead-Of-Time (AOT) compilation, but it appears that hook generation needs runtime reflection. Additionally, the trimmer seems to strip away important types like Reloaded.Memory.Sources.IMemory. This issue complicates the use of Reloaded.Hooks in AOT scenarios.

Would it be possible to provide reflection-less & trimming-friendly hooks?

Use Case

I am running the hooker outside the regular Reloaded-II runtime/injector, and instead, compiling as a native dinput8.dll proxy that's placed in the target folder. See here

Expected Behavior:

An AOT compiled project depending on Reloaded.Hooks should build without warnings and install hooks without runtime exceptions.

Actual Behavior

The application builds with warnings, and at runtime, it fails to load Reloaded.Memory.Sources.IMemory on new Hook<T>() due to the trimming process removing necessary components.

valters-tomsons avatar May 25 '24 13:05 valters-tomsons