LiteLDev/LiteLoader.NET

Hook委托会被GC回收

Yushu2606 opened this issue · 1 comments

Process terminated. A callback was made on a garbage collected delegate of type 'Ptrarc!Hide_Seed_HookDelegate::Invoke'.

internal delegate void Hide_Seed_HookDelegate(IntPtr a1, IntPtr a2);
[HookSymbol("?write@StartGamePacket@@UEBAXAEAVBinaryStream@@@Z")]
internal class Hide_Seed_Hook : THookBase<Hide_Seed_HookDelegate> {
    public override Hide_Seed_HookDelegate Hook =>
        (IntPtr a1, IntPtr a2) => {
            Marshal.WriteInt32(HookAPI.dAccess(a1, 48), 0);
            Original(a1, a2);
        };
}
Pd233 commented

那我换种实现好了