private IntPtr HookAdd(UcHookType type, Delegate callback, Delegate userCallback, object userData = null, ulong begin = 1, ulong end = 0) { var callbackId = _callbackId++; var callbackData = new UnicornCallbackData(callback, userCallback, userData); var err = UcNative.UcHookAdd(Handle, out var result, type, callback, new IntPtr(callbackId), begin, end); if (err != UcErr.UC_ERR_OK) { throw new UcException(err); } _callbacks.Add(callbackId, callbackData); return(result); }