Example #1
0
 internal static extern IntPtr Disassemble(
     [In] SafeCapstoneContextHandle pHandle,
     [In] byte[] pCode,
     [In] IntPtr codeSize,
     [In] ulong startingAddress,
     [In] IntPtr count,
     [Out] out IntPtr /* cs_insn * */ instruction);
        /// <summary>This is a required override. The method invokes the Capstone
        /// provided native function that will release the handle.</summary>
        /// <returns>True on successfull handle release, false otherwise.</returns>
        /// <remarks>TODO : if the handle is not properly released by the native
        /// library, we should consider throwing an exception instead of returning
        /// a boolean. This is almost certainly an unex^pected condition that require
        /// some kind of fix.</remarks>
        protected override bool ReleaseHandle()
        {
            // We must use a local variable in order to be able to use the ref modifier
            // on Close call.
            SafeCapstoneContextHandle mySelf = this;

            if (IntPtr.Zero == mySelf.handle)
            {
                throw new InvalidOperationException();
            }
            CapstoneImport.Close(ref mySelf).ThrowOnCapstoneError();
            // We need to reset the handle by ourselves.
            this.handle = IntPtr.Zero;
            return(true);
        }
Example #3
0
 internal static extern int CountOperands(
     [In] SafeCapstoneContextHandle pHandle,
     [In] IntPtr /* cs_insn * */ insn,
     [In] uint op_type);
Example #4
0
 internal static extern bool BelongsToGroup(
     [In] SafeCapstoneContextHandle pHandle,
     [In] IntPtr /* cs_insn * */ insn,
     [In] uint group_id);
Example #5
0
 internal static extern CapstoneErrorCode Close(
     [In, Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(SafeCapstoneContextHandle.RefMarshaler))] ref SafeCapstoneContextHandle pHandle);
Example #6
0
 internal static extern string RegistryName(
     [In] SafeCapstoneContextHandle pHandle,
     [In] uint registryId);
Example #7
0
 internal static extern CapstoneErrorCode SetOption(
     [In] SafeCapstoneContextHandle pHandle,
     [In] DisassembleOptionType option,
     [In] IntPtr value);
Example #8
0
 internal static extern string InstructionName(
     [In] SafeCapstoneContextHandle pHandle,
     [In] uint instructionId);
Example #9
0
 internal static extern bool IsRegisterWrite(
     [In] SafeCapstoneContextHandle pHandle,
     [In] IntPtr /* cs_insn * */ insn,
     [In] uint reg_id);
Example #10
0
 internal static extern string GroupName(
     [In] SafeCapstoneContextHandle pHandle,
     [In] uint groupId);
Example #11
0
 internal static extern int GetOperandIndex(
     [In] SafeCapstoneContextHandle pHandle,
     [In] IntPtr /* cs_insn * */ insn,
     [In] uint op_type,
     [In] uint position);
Example #12
0
 internal static extern CapstoneErrorCode GetLastError(
     [In] SafeCapstoneContextHandle pHandle);
Example #13
0
 internal static extern SafeNativeInstructionHandle AllocateInstruction(
     [In] SafeCapstoneContextHandle pHandle);
Example #14
0
 internal static extern bool DisassembleIteratively(
     [In] SafeCapstoneContextHandle pHandle,
     [In, Out] ref IntPtr /* uint8_t ** */ code,
     [In, Out] ref IntPtr codeSize,
     [In, Out] ref ulong address,
     [In] SafeNativeInstructionHandle /* cs_insn * */ insn);