Exemplo n.º 1
0
        /// <summary>
        /// Base method to add a hook to <see cref="Emulator"/>.
        /// </summary>
        /// <param name="type">Type of hook.</param>
        /// <param name="callback">Pointer to callback method.</param>
        /// <param name="begin">Start address of where the hook is effective (inclusive).</param>
        /// <param name="end">End address of where the hook is effective (inclusive).</param>
        /// <returns>A <see cref="HookHandle"/> which represents hook.</returns>
        protected HookHandle Add(UnicornHookType type, Delegate callback, ulong begin, ulong end)
        {
            //NOTE: Not calling Emulator.CheckDispose() here because the caller should take responsibility of doing so.

            var hh          = IntPtr.Zero;
            var callbackPtr = Marshal.GetFunctionPointerForDelegate(callback);

            Emulator.Bindings.HookAdd(Emulator.Handle, ref hh, type, callbackPtr, IntPtr.Zero, begin, end);

            var handle = new HookHandle(hh, callback);

            _handles.Add(handle);

            return(handle);
        }
Exemplo n.º 2
0
 public void HookAdd(IntPtr uc, ref IntPtr hh, UnicornHookType type, IntPtr callback, IntPtr userData, ulong address, ulong end, int instruction)
 => ThrowIfError(uc_hook_add(uc, ref hh, (uc_hook_type)type, callback, userData, address, end, instruction));