public static bool Run(byte[] bytes, string entry, uint memSize, uint stackSize, OnProcessOp onProcessOp, OnError onError = null) { IntPtr buffer = Marshal.AllocHGlobal(bytes.Length); Marshal.Copy(bytes, 0, buffer, bytes.Length); var result = false; try { result = NAPI.Run( buffer, (UIntPtr)bytes.Length, entry, (UIntPtr)memSize, (UIntPtr)stackSize, (context, op, paramsPtrs, paramsCount, targetsPtrs, targetsCount) => { onProcessOp?.Invoke(op, MakePointers(paramsPtrs, paramsCount), MakePointers(targetsPtrs, targetsCount)); }, IntPtr.Zero, (context, error) => onError?.Invoke(error), IntPtr.Zero ); } catch (Exception error) { onError?.Invoke(error.Message); } finally { Marshal.FreeHGlobal(buffer); } return(result); }
public static bool Resume(UIntPtr handle, OnProcessOp onProcessOp, OnError onError = null) { var result = false; try { result = NAPI.Resume( handle, (context, op, paramsPtrs, paramsCount, targetsPtrs, targetsCount) => { onProcessOp?.Invoke(op, MakePointers(paramsPtrs, paramsCount), MakePointers(targetsPtrs, targetsCount)); }, IntPtr.Zero, (context, error) => onError?.Invoke(error), IntPtr.Zero ); } catch (Exception error) { onError?.Invoke(error.Message); } return(result); }