コード例 #1
0
        /// <summary>
        ///     Get an Instruction's Details.
        /// </summary>
        /// <param name="instruction">
        ///     An instruction.
        /// </param>
        /// <returns>
        ///     The instruction's details. A null reference indicates the instruction was disassembled without
        ///     details.
        /// </returns>
        internal static NativeInstructionDetail?GetInstructionDetail(ref NativeInstruction instruction)
        {
            NativeInstructionDetail?instructionDetails = null;

            if (instruction.Details != IntPtr.Zero)
            {
                // ...
                //
                // Throws an exception if the operation fails.
                var pInstructionDetails = instruction.Details;
                instructionDetails = MarshalExtension.PtrToStructure <NativeInstructionDetail>(pInstructionDetails);
            }

            return(instructionDetails);
        }
コード例 #2
0
        /// <summary>
        ///     Get an Instruction's Architecture Specific Details.
        /// </summary>
        /// <typeparam name="TInstructionDetails">
        ///     The type of the instruction's architecture specific details.
        /// </typeparam>
        /// <param name="instruction">
        ///     An instruction.
        /// </param>
        /// <returns>
        ///     The instruction's architecture specific details. A null reference indicates the instruction was
        ///     disassembled without its details.
        /// </returns>
        internal static TInstructionDetails?GetInstructionDetail <TInstructionDetails>(ref NativeInstruction instruction) where TInstructionDetails : struct
        {
            TInstructionDetails?instructionDetails = null;

            if (instruction.Details != IntPtr.Zero)
            {
                // ...
                //
                // Throws an exception if the operation fails.
                var pInstructionDetails = instruction.Details + NativeCapstone.MagicInstructionArchitectureDetailsFieldOffset;
                instructionDetails = MarshalExtension.PtrToStructure <TInstructionDetails>(pInstructionDetails);
            }

            return(instructionDetails);
        }