Files
LegacyWeaveLoader/WeaveLoader.API/Native/NativeInvoker.cs
2026-03-10 17:45:25 -05:00

24 lines
859 B
C#

namespace WeaveLoader.API.Native;
internal static class NativeInvoker
{
internal static bool TryInvoke(string fullName, nint thisPtr, bool hasThis, NativeType retType, NativeArg[] args, out NativeRet ret)
{
ret = new NativeRet { Type = retType };
nint fn = NativeSymbol.Find(fullName);
if (fn == 0)
return false;
int ok = NativeInterop.native_invoke(fn, thisPtr, hasThis ? 1 : 0, args, args.Length, ref ret);
return ok != 0;
}
internal static bool TryInvoke(nint fn, nint thisPtr, bool hasThis, NativeType retType, NativeArg[] args, out NativeRet ret)
{
ret = new NativeRet { Type = retType };
if (fn == 0)
return false;
int ok = NativeInterop.native_invoke(fn, thisPtr, hasThis ? 1 : 0, args, args.Length, ref ret);
return ok != 0;
}
}