Verified Commit b70ec4dd authored by GovanifY's avatar GovanifY
Browse files

rust bindings

parent 4a2e8fc4
......@@ -10,3 +10,5 @@ release.zip
build/
bin/
obj/
target/
Cargo.lock
......@@ -29,7 +29,6 @@ namespace csharp
[DllImport(libipc)]
static extern UInt32 GetError(IntPtr v);
static void Main(string[] args)
{
// we get our ipc object
......@@ -41,6 +40,9 @@ namespace csharp
// we check for errors
Console.WriteLine("Error (if any): {0}", GetError(ipc));
// we delete the object and free the resources
deletePCSX2Ipc(ipc);
// for more infos check out the C bindings documentation :D !
}
}
......
......@@ -2,3 +2,4 @@ C# bindings for the IPC lib.
This requires you to build the C library for your OS first.
Refer to `bindings/c` for that.
Once done make sure the library is in your build and/or execution folders.
......@@ -2,3 +2,4 @@ Python bindings for the IPC lib.
This requires you to build the C library for your OS first.
Refer to `bindings/c` for that.
Once done make sure the library is in your build and/or execution folders.
......@@ -27,5 +27,7 @@ print(libipc.Read(ipc, 0x00347D34, 0, False))
# we check for errors
print("Error (if any): " + str(libipc.GetError(ipc)))
# we delete the object and free the resources
libipc.deletePCSX2Ipc(ipc)
# for more infos check out the C bindings documentation :D !
[package]
name = "rust"
version = "0.1.0"
authors = ["Gauvain 'GovanifY' Roussel-Tarbouriech <gauvain@govanify.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
libc = "*"
Rust bindings for the IPC lib.
This requires you to build the C library for your OS first.
Refer to `bindings/c` for that.
Once done make sure the library is in your build and/or execution folders.
use std::path::Path;
use std::env;
fn main() {
let dir = env::current_dir().unwrap();
println!("cargo:rustc-link-search=native={}", Path::new(&dir).display());
}
extern crate libc;
use libc::{c_char, c_uint, c_ulong};
#[repr(C)] pub struct PCSX2Ipc { _private: [u8; 0] }
#[link(name = "pcsx2_ipc_c")]
extern "C" {
/* I defined the functions I wanted to use for the example
* below but if you need other ones you'll have to
* define them here, it's not too hard, just be sure
* to look up Rust FFI documentation. */
fn newPCSX2Ipc() -> *mut PCSX2Ipc;
fn Read(v: *mut PCSX2Ipc, address: c_uint, msg: c_char, batch: bool) -> c_ulong;
fn deletePCSX2Ipc(v: *mut PCSX2Ipc);
fn GetError(v: *mut PCSX2Ipc) -> c_uint;
}
fn main() {
unsafe {
// we get our ipc object
let _ipc = newPCSX2Ipc();
// we read an uint8_t from memory location 0x00347D34
println!("{}", Read(_ipc, 0x00347D34, 0x00, false));
// we check for errors
println!("Error (if any): {}", GetError(_ipc));
// we delete the object and free the resources
deletePCSX2Ipc(_ipc);
// for more infos check out the C bindings documentation :D !
}
}
......@@ -14,9 +14,11 @@ pkgs.mkShell {
newunicodechar etoc; })
pkgs.dotnet-sdk_3
pkgs.pythonPackages.pip
pkgs.cargo
];
# clang is pretty nice
shellHook = ''
export CXX="clang++"
export CARGO_HOME=$HOME/.cache/cargo
'';
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment