Commit Graph

8 Commits

Author SHA1 Message Date
peelz
2cdd3f3ec5 Add constructor support to Hook.Patch 2022-09-15 19:31:47 -04:00
peelz
dd1b404c9b Refactor error/exception/message handling
This adds:
- LuaCsSetup.ExceptionHandler so we can decide how we want to handle
exceptions for unit tests
- LuaCsSetup.MessageHandler so we can redirect logs to the XUnit output
  helper
2022-08-10 05:59:41 -04:00
peelz
69c627b651 Deprecate Hook.HookMethod 2022-08-10 05:36:16 -04:00
peelz
08836088fb Refactor hooking API
This completely changes how method patching works under the hood. Unlike
the previous API (`Hook.HookMethod`), the new API (`Hook.Patch`)
generates a Harmony patch method at runtime, using IL generation.

This fixes methods with ByRef (out/ref) parameters getting silently corrupted
due to the ByRef semantics being lost when passed through the `object[] __args`
parameter.

This new API also makes it possible to:
  - modify parameters (including ByRef params)
  - change the return value to `null` (old API would use `return nil`
    for Harmony control flow)
  - prevent execution of the original method (and other harmony
    patches), independently of modifying the return value
2022-08-09 17:50:00 -04:00
peelz
768abd5ce1 Remove LuaResult 2022-08-09 17:50:00 -04:00
peelz
a5bffce33b Move prohibitedHooks check to a method 2022-08-09 17:50:00 -04:00
Evil Factory
b9ebf04a6a fix undefined identifiers in patches overriding each other 2022-07-14 20:55:39 -03:00
Evil Factory
4ad3b2cba0 Decursefication of patches 2022-06-29 16:13:51 -03:00