Ejemplo n.º 1
0
    public static string ErrorToString(KeystoneError result)
    {
        IntPtr intPtr = KeystoneImports.ErrorToString(result);

        if (intPtr != IntPtr.Zero)
        {
            return(Marshal.PtrToStringAnsi(intPtr));
        }
        return(string.Empty);
    }
Ejemplo n.º 2
0
    public Keystone(KeystoneArchitecture architecture, KeystoneMode mode, bool throwOnKeystoneError = true)
    {
        internalImpl = this.SymbolResolver;
        throwOnError = throwOnKeystoneError;
        KeystoneError keystoneError = KeystoneImports.Open(architecture, (int)mode, ref engine);

        if (keystoneError != 0 && throwOnKeystoneError)
        {
            throw new InvalidOperationException($"Error while initializing keystone: {ErrorToString(keystoneError)}");
        }
    }
Ejemplo n.º 3
0
        /// <summary>
        ///   Returns the string associated with a given error code.
        /// </summary>
        public static string ErrorToString(KeystoneError code)
        {
            IntPtr error = NativeInterop.ErrorToString(code);

            if (error != IntPtr.Zero)
            {
                return(Marshal.PtrToStringAnsi(error));
            }

            return(string.Empty);
        }
Ejemplo n.º 4
0
        public bool SetOption(KeystoneOptionType type, uint value)
        {
            KeystoneError result = KeystoneImports.SetOption(this.engine, type, (IntPtr)(long)value);

            if (result == KeystoneError.KS_ERR_OK)
            {
                return(true);
            }
            if (this.throwOnError)
            {
                throw new InvalidOperationException(string.Format("Error while setting option in keystone: {0}", (object)Keystone.ErrorToString(result)));
            }
            return(false);
        }
Ejemplo n.º 5
0
        public Keystone(
            KeystoneArchitecture architecture,
            KeystoneMode mode,
            bool throwOnKeystoneError = true)
        {
            this.internalImpl = new Keystone.ResolverInternal(this.SymbolResolver);
            this.throwOnError = throwOnKeystoneError;
            KeystoneError result = KeystoneImports.Open(architecture, (int)mode, ref this.engine);

            if ((uint)result > 0U & throwOnKeystoneError)
            {
                throw new InvalidOperationException(string.Format("Error while initializing keystone: {0}", (object)Keystone.ErrorToString(result)));
            }
        }
Ejemplo n.º 6
0
    public bool SetOption(KeystoneOptionType type, uint value)
    {
        KeystoneError keystoneError = KeystoneImports.SetOption(engine, type, (IntPtr)(long)value);

        if (keystoneError != 0)
        {
            if (throwOnError)
            {
                throw new InvalidOperationException($"Error while setting option in keystone: {ErrorToString(keystoneError)}");
            }
            return(false);
        }
        return(true);
    }
Ejemplo n.º 7
0
        public static string ErrorToString(KeystoneError result)
        {
            IntPtr ptr = KeystoneImports.ErrorToString(result);

            return(ptr != IntPtr.Zero ? Marshal.PtrToStringAnsi(ptr) : string.Empty);
        }
Ejemplo n.º 8
0
 internal extern static IntPtr ErrorToString(KeystoneError code);
Ejemplo n.º 9
0
 internal static extern IntPtr ErrorToString(KeystoneError code);
Ejemplo n.º 10
0
        internal KeystoneException(string message, KeystoneError error) : base(message + '.')
        {
            Debug.Assert(error != KeystoneError.KS_ERR_OK);

            Error = error;
        }