Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public KeystoneEncoded Assemble(string toEncode, ulong address)
        {
            IntPtr encoding;
            uint   size;
            uint   statements;

            if (KeystoneImports.Assemble(this.engine, toEncode, address, out encoding, out size, out statements) != 0)
            {
                if (this.throwOnError)
                {
                    throw new InvalidOperationException(string.Format("Error while assembling {0}: {1}", (object)toEncode, (object)Keystone.ErrorToString(this.GetLastKeystoneError())));
                }
                return((KeystoneEncoded)null);
            }
            byte[] numArray = new byte[(int)size];
            Marshal.Copy(encoding, numArray, 0, (int)size);
            KeystoneImports.Free(encoding);
            return(new KeystoneEncoded(numArray, statements, address));
        }
Exemplo n.º 3
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)));
            }
        }