diff --git a/CREDITS.TXT b/CREDITS.TXT
index 46f0a968..0840bab5 100644
--- a/CREDITS.TXT
+++ b/CREDITS.TXT
@@ -49,5 +49,5 @@ Ruben Boonen: PowerShell binding.
Marco Fornaro: C# binding.
David Zimmer: VB6 binding.
Michael Mohr: Debian packaging.
-Jämes Ménétrey (ZenLulz): Java binding.
+Jämes Ménétrey (ZenLulz): Java and C# bindings.
Philippe Antoine (Catena cyber): fuzzing.
diff --git a/bindings/README b/bindings/README
index db565131..5a996a72 100644
--- a/bindings/README
+++ b/bindings/README
@@ -10,7 +10,7 @@ Except Python, all other bindings are contributed by community.
- Haskell binding: by Adrian Herrera
- OCaml binding: by Aziem Chawdhary
- PowerShell binding: by Ruben Boonen
-- C# binding: by Marco Fornaro
+- C# binding: by Marco Fornaro and Jämes Ménétrey (ZenLulz)
- VB6 binding: by David Zimmer
- Masm binding: by mrfearless
- Java binding: by Jämes Ménétrey (ZenLulz)
diff --git a/bindings/csharp/.gitignore b/bindings/csharp/.gitignore
index dd5d9ca6..3b9d5ec6 100644
--- a/bindings/csharp/.gitignore
+++ b/bindings/csharp/.gitignore
@@ -146,8 +146,6 @@ publish/
#*.pubxml
*.publishproj
-# NuGet Packages
-*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
diff --git a/bindings/csharp/CHANGELOG.md b/bindings/csharp/CHANGELOG.md
new file mode 100755
index 00000000..9cd5d757
--- /dev/null
+++ b/bindings/csharp/CHANGELOG.md
@@ -0,0 +1,11 @@
+# Changelog of the .NET bindings for Keystone
+
+**Version 0.9.1.1: May 18th, 2019**:
+
+- Update to .NET Standard 2.0.
+- Load dynamically the dynamic-link library that corresponds to the architecture of the running process (32 or 64-bit).
+
+
+**Version 0.9.1.0: August 2nd, 2018**:
+
+- Refactor the bindings to target .NET Standard 1.1.
\ No newline at end of file
diff --git a/bindings/csharp/Keystone.Net.Tests/Keystone.Net.Tests.csproj b/bindings/csharp/Keystone.Net.Tests/Keystone.Net.Tests.csproj
old mode 100644
new mode 100755
diff --git a/bindings/csharp/Keystone.Net/Keystone.Net.csproj b/bindings/csharp/Keystone.Net/Keystone.Net.csproj
old mode 100644
new mode 100755
index ab55366f..8f5bec3d
--- a/bindings/csharp/Keystone.Net/Keystone.Net.csproj
+++ b/bindings/csharp/Keystone.Net/Keystone.Net.csproj
@@ -1,28 +1,36 @@
- netstandard1.1
+ netstandard2.0
Keystone
- 1.1.0
- $(Version)
- $(Version).0
+ 0.9.1.1
+ 0.9.1.1
+ 0.9.1.1
- .NET bindings to the Keystone Engine.
- Grégoire Geis
+ Keystone is a lightweight multi-platform, multi-architecture assembler framework. This package corresponds to the csharp bindings in the official git repository.
+ Nguyen Anh Quynh, Marco Fornaro, Grégoire Geis, Jämes Ménétrey
- Keystone.Net
+ keystoneengine.csharp
$(Version)
- False
- - First release.
- assembler x86 arm keystone
+ true
+ Release notes can be found at: https://github.com/keystone-engine/keystone/blob/0.9.1/ChangeLog
+ assembler x86 x64 arm keystone llvm
- https://github.com/keystone-engine/keystone
- $(PackageProjectUrl)/blob/master/COPYING
+ http://www.keystone-engine.org
+ https://github.com/keystone-engine/keystone#license
http://www.keystone-engine.org/images/keystone.png
- $(PackageProjectUrl).git
+ https://github.com/keystone-engine/keystone
git
+
+ Nguyen Anh Quynh
+ true
+ Keystone Engine - .NET Bindings
+
+
+
+ true
diff --git a/bindings/csharp/Keystone.Net/NativeInterop.cs b/bindings/csharp/Keystone.Net/NativeInterop.cs
old mode 100644
new mode 100755
index b910e2fa..6e76692d
--- a/bindings/csharp/Keystone.Net/NativeInterop.cs
+++ b/bindings/csharp/Keystone.Net/NativeInterop.cs
@@ -1,4 +1,5 @@
using System;
+using System.IO;
using System.Runtime.InteropServices;
namespace Keystone
@@ -8,29 +9,34 @@ namespace Keystone
///
internal class NativeInterop
{
- // This shouldn't be needed, even on Windows
- // ///
- // /// Taken from: http://stackoverflow.com/questions/10852634/using-a-32bit-or-64bit-dll-in-c-sharp-dllimport
- // ///
- // static NativeInterop()
- // {
- // var myPath = new Uri(typeof(NativeInterop).Assembly.CodeBase).LocalPath;
- // var myFolder = Path.GetDirectoryName(myPath);
+ ///
+ /// Load the appropriate dynamic-link library, according the architecture of the running application.
+ ///
+ ///
+ /// Taken from: http://stackoverflow.com/questions/10852634/using-a-32bit-or-64bit-dll-in-c-sharp-dllimport
+ ///
+ static NativeInterop()
+ {
+ var libPath = Path.GetDirectoryName(new Uri(typeof(NativeInterop).Assembly.CodeBase).LocalPath);
+ var is64 = IntPtr.Size == 8;
+ var subfolder = is64 ? "x64" : "x86";
- // var is64 = IntPtr.Size == 8;
- // var subfolder = is64 ? "\\win64\\" : "\\win32\\";
+ if (!string.IsNullOrEmpty(libPath))
+ {
+ var dllPosition = Path.Combine(libPath, subfolder, "keystone.dll");
- // string dllPosition = myFolder + subfolder + "keystone.dll";
+ // If this file exist, load it.
+ // Otherwise let the marshaller load the appropriate file.
+ if (File.Exists(dllPosition))
+ {
+ LoadLibrary(dllPosition);
+ }
+ }
+ }
- // // If this file exist, load it.
- // // Otherwise let the marshaller load the appropriate file.
- // if (File.Exists(dllPosition))
- // LoadLibrary(dllPosition);
- // }
+ [DllImport("kernel32.dll")]
+ private static extern IntPtr LoadLibrary(string dllToLoad);
- // [DllImport("kernel32.dll")]
- // private static extern IntPtr LoadLibrary(string dllToLoad);
-
[DllImport("keystone", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ks_version" )]
internal static extern uint Version(ref uint major, ref uint minor);
diff --git a/bindings/csharp/README.md b/bindings/csharp/README.md
index 7e7e7688..8a353a13 100644
--- a/bindings/csharp/README.md
+++ b/bindings/csharp/README.md
@@ -1,5 +1,5 @@
-# Keystone.Net
-.NET Standard bindings for Keystone.
+# Keystone.Net
+.NET bindings for Keystone (.NET Standard 2.0), written in C#.
## Usage
```csharp
@@ -30,3 +30,36 @@ using (Engine keystone = new Engine(Architecture.X86, Mode.X32) { ThrowOnError =
For those who already used the bindings before their last update, many things have changed.
You can migrate your existing code easily using the [migration guide](./MIGRATON.md).
+
+## NuGet package
+The NuGet package `keystoneengine.csharp` is maintained to reflect the latest version of the bindings and the library. It can either be downloaded using Visual Studio or by [browsing NuGet directly](https://www.nuget.org/packages/keystoneengine.csharp/). The package already embeds the 32/64-bit native dynamic-link libraries of Keystone.
+
+## Found an issue or bug ?
+Feel free to open a GitHub issue on [the official repository of Keystone](https://github.com/keystone-engine/keystone/issues) and ping the contributors.
+
+
+## Contributors
+Authors:
+
+- Grégoire Geis ([https://github.com/71](@71))
+- Jämes Ménétrey ([@ZenLulz](https://github.com/ZenLulz/))
+- Marco Fornaro ([@chaplin89](https://github.com/chaplin89))
+
+### Want to contribute ?
+Hey you! Your help is more than welcome! Things to keep in mind when working on the .NET bindings for Keystone:
+
+- Think about the backward compatibility; while code refactoring is a good practice, changing entirely the API *may* result in struggles.
+- Elaborate the unit tests that prove your code is working. Test all the paths of the newly added functions/classes. Keep the code coverage high!
+- Please; write the required *XML Documentation Comments*, so every developer has the chance to understand your code.
+- Update the changelog with a summary of your changes.
+
+#### Version notation
+The version of the .NET bindings for Keystone is indicated in the Visual Studio project file. The major, minor and incremental versions (w.x.y) match the version of the library Keystone that the bindings are developed with. The build number (the .z in w.x.y.z) is incremented for each newer version of the .NET bindings. Please, don't forget to increment this version when you submit a pull request.
+
+On the last commit for a pull request, please create a tag called `csharp-bindings-w.x.y.z`.
+
+#### Pull request submission
+Ping the contributors of the .NET bindings when submitting a pull request, so your changes can be peer reviewed.
+
+#### NuGet package update
+Once your pull request has been accepted, please contact [@ZenLulz](https://github.com/ZenLulz/) so either he updates the library for you or add you to the project as a contributor on nuget.org. An example of *nupkg* is provided in this folder, as it requires to have a very specific configuration, because it embeds unmanaged libraries. The picture *nuget-package-config.png* details the structure and content of a NuGet package, ready to be deployed. Please reuse and test the package before pushing it onto nuget.org, as there is no possible roll back.
\ No newline at end of file
diff --git a/bindings/csharp/keystoneengine.csharp.nupkg b/bindings/csharp/keystoneengine.csharp.nupkg
new file mode 100755
index 00000000..4adfb72c
Binary files /dev/null and b/bindings/csharp/keystoneengine.csharp.nupkg differ
diff --git a/bindings/csharp/nuget-package-config.png b/bindings/csharp/nuget-package-config.png
new file mode 100755
index 00000000..25891b41
Binary files /dev/null and b/bindings/csharp/nuget-package-config.png differ