Example #1
0
        /// <summary>
        ///     Set Disassemble Mode Option.
        /// </summary>
        /// <param name="handle">
        ///     A Capstone handle. Should not be a null reference.
        /// </param>
        /// <param name="mode">
        ///     A disassemble mode.
        /// </param>
        /// <exception cref="System.InvalidOperationException">
        ///     Thrown if the disassemble mode option could not be set.
        /// </exception>
        public static void SetDisassembleModeOption(SafeCapstoneHandle handle, DisassembleMode mode)
        {
            var       pHandle = handle.DangerousGetHandle();
            const int iOption = (int)DisassembleOptionType.Mode;

            // Set Disassemble Option.
            //
            // ...
            var resultCode = CapstoneImport.SetOption(pHandle, iOption, (IntPtr)mode);

            if (resultCode != (int)DisassembleErrorCode.Ok)
            {
                throw new InvalidOperationException("Unable to set disassemble mode option.");
            }
        }
        /// <summary>
        ///     Set Disassemble Syntax Option.
        /// </summary>
        /// <param name="handle">
        ///     A Capstone handle. Should not be a null reference.
        /// </param>
        /// <param name="value">
        ///     A syntax option value.
        /// </param>
        /// <exception cref="System.InvalidOperationException">
        ///     Thrown if the disassemble syntax option could not be set.
        /// </exception>
        public static void SetDisassembleSyntaxOption(SafeCapstoneHandle handle, DisassembleSyntaxOptionValue value)
        {
            // var pHandle = handle.DangerousGetHandle();
            const int iOption = (int)DisassembleOptionType.Syntax;

            // Set Disassemble Option.
            //
            // ...
            var resultCode = CapstoneImport.SetOption(unchecked ((UIntPtr)(ulong)(ulong)handle.DangerousGetHandle()),
                                                      iOption, (UIntPtr)value);

            if (resultCode != (int)DisassembleErrorCode.Ok)
            {
                throw new InvalidOperationException("Unable to set disassemble syntax option.");
            }
        }
Example #3
0
        /// <summary>
        ///     Set Disassemble Details Option.
        /// </summary>
        /// <param name="handle">
        ///     A Capstone handle. Should not be a null reference.
        /// </param>
        /// <param name="flag">
        ///     A flag indicating whether to disable or enable the disassemble details option.
        /// </param>
        /// <exception cref="System.InvalidOperationException">
        ///     Thrown if the disassemble details option could not be set.
        /// </exception>
        public static void SetDisassembleDetails(SafeCapstoneHandle handle, bool flag)
        {
            var       pHandle = handle.DangerousGetHandle();
            const int iOption = (int)DisassembleOptionType.Detail;
            var       value   = flag ? (IntPtr)DisassembleOptionValue.On : (IntPtr)DisassembleOptionValue.Off;

            // Set Disassemble Option.
            //
            // ...
            var resultCode = CapstoneImport.SetOption(pHandle, iOption, value);

            if (resultCode != (int)DisassembleErrorCode.Ok)
            {
                throw new InvalidOperationException("Unable to set disassemble details option.");
            }
        }