You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.4 KiB
2.4 KiB
Changes
Names
- The
KeystoneNET
namespace was renamed toKeystone
. - The
Keystone
andKeystoneEncoded
classes were respectively renamed toEngine
andEncodedData
. - The
KeystoneArchitecture
,KeystoneMode
,KeystoneOptionType
andKeystoneOptionValue
enums had their names changed, dropping theKeystone
prefix (ie:Architecture
,Mode
, ...). Furthermore, their members were renamed, dropping theKS_MODE_
,KS_ARCH_
, andKS_OPT_
prefixes.
The Engine
class
- The
Engine
constructor no longer takesbool throwOnError
. Instead, the publicThrowOnError
property now has both a getter and a setter, making it possible to alter the error behavior after initialization. - Errors are no longer reported as
InvalidOperationException
, but instead asKeystoneException
, a custom class which stores the returned error code. - An error encountered in the constructor or when setting
ResolveSymbol
will throw an exception, regardless of the value ofThrowOnError
. AppendAssemble
was renamed toAssemble
, and no longer acceptsICollection<byte>
. Instead it accepts abyte[]
buffer and anint
index, and writes much more efficiently into it. A new overload accepting aStream
has also been added.- The
out uint statements
parameter has been replaced by anout int statementCount
parameter. It will always be positive, but better integrates into the C# language.
Examples
Namespace
using KeystoneNET;
becomes
using Keystone;
Initialization
using (var ks = new Keystone(KeystoneArchitecture.KS_ARCH_X86,
KeystoneMode.KS_MODE_32,
throwOnError: false))
{
}
becomes
using (var ks = new Engine(Architecture.X86, Mode.X32)
{ ThrowOnError = true })
{
}
Catching errors
try
{
ks.SymbolResolver += Callback;
}
catch (InvalidOperationException e)
{
Console.WriteLine(e);
}
becomes
try
{
ks.SymbolResolver += Callback;
}
catch (KeystoneException e)
{
Console.WriteLine(e);
}
Assembling data
var data = new List<byte>();
ks.AppendAssemble("add eax, eax", data);
becomes
var data = new byte[1024];
ks.Assemble("add eax, eax", data);
or
using (var ms = new MemoryStream())
{
ks.Assemble("add eax, eax", ms);
}