SSV_INITLIB2 SSV_LireCartePS
This commit is contained in:
parent
4162e55b83
commit
7694f5f102
32
Cargo.lock
generated
Normal file
32
Cargo.lock
generated
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clego"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi"
|
||||||
|
version = "0.3.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-i686-pc-windows-gnu",
|
||||||
|
"winapi-x86_64-pc-windows-gnu",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-i686-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-x86_64-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
@ -1,7 +1,5 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"webapp",
|
"clego"
|
||||||
"clego",
|
|
||||||
"tauri",
|
|
||||||
]
|
]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
@ -4,3 +4,4 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
winapi = { version = "0.3.8", features = ["winuser","libloaderapi"] }
|
||||||
|
63
clego/src/SV_DLL_Win.rs
Normal file
63
clego/src/SV_DLL_Win.rs
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
extern crate winapi;
|
||||||
|
|
||||||
|
use winapi::um::libloaderapi::{ LoadLibraryA, GetProcAddress};
|
||||||
|
|
||||||
|
use std::ffi::{CString , c_void};
|
||||||
|
|
||||||
|
// Définissez une énumération pour les deux types possibles
|
||||||
|
|
||||||
|
|
||||||
|
//récupérer le handle sur la library
|
||||||
|
fn load_library(dll_path: &str)->*mut winapi::shared::minwindef::HINSTANCE__ {
|
||||||
|
let dll_path_c = CString::new(dll_path).expect("Chemin de DLL invalide");
|
||||||
|
unsafe {
|
||||||
|
let h_module = LoadLibraryA(dll_path_c.as_ptr());
|
||||||
|
h_module
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//SSV_INITLIB2
|
||||||
|
fn ssv_initlib2(dll_handle:*mut winapi::shared::minwindef::HINSTANCE__ , sesamini_path :String)->i32{
|
||||||
|
// Résolution d'une fonction exportée ("SSV_InitLIB2")
|
||||||
|
let symbol_name = CString::new("SSV_InitLIB2").expect("Nom de symbole invalide");
|
||||||
|
unsafe {
|
||||||
|
let function_ptr = GetProcAddress(dll_handle, symbol_name.as_ptr());
|
||||||
|
|
||||||
|
if function_ptr.is_null() { panic!("Échec de la résolution du symbole");}
|
||||||
|
|
||||||
|
// Convertir le pointeur en une fonction Rust
|
||||||
|
type MyFunctionType = unsafe extern "C" fn(*const i8) -> i32;
|
||||||
|
let my_function: MyFunctionType = std::mem::transmute(function_ptr);
|
||||||
|
|
||||||
|
let result = my_function(
|
||||||
|
CString::new(sesamini_path).unwrap().as_ptr()
|
||||||
|
);
|
||||||
|
result
|
||||||
|
}}
|
||||||
|
|
||||||
|
//SSV_LireCartePS
|
||||||
|
fn ssv_lirecarteps(dll_handle:*mut winapi::shared::minwindef::HINSTANCE__ , NomRessourcePS :String , NomRessourceLecteur :String , CodePorteurPS :String,
|
||||||
|
mut ZDonneesSortie: *mut c_void , mut TTailleDonneesSortie: usize)->i32{
|
||||||
|
// Résolution d'une fonction exportée ("SSV_LireCartePS")
|
||||||
|
let symbol_name = CString::new("SSV_LireCartePS").expect("Nom de symbole invalide");
|
||||||
|
unsafe {
|
||||||
|
let function_ptr = GetProcAddress(dll_handle, symbol_name.as_ptr());
|
||||||
|
if function_ptr.is_null() {
|
||||||
|
panic!("Échec de la résolution du symbole");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convertir le pointeur en une fonction Rust
|
||||||
|
type MyFunctionType = unsafe extern "C" fn(*const i8, *const i8, *const i8, *mut *mut c_void, *mut usize) -> i32;
|
||||||
|
let my_function: MyFunctionType = std::mem::transmute(function_ptr);
|
||||||
|
|
||||||
|
// appel de la fonction
|
||||||
|
ZDonneesSortie= std::ptr::null_mut();
|
||||||
|
TTailleDonneesSortie=0;
|
||||||
|
let result = my_function(CString::new(NomRessourcePS).unwrap().as_ptr(),
|
||||||
|
CString::new(NomRessourceLecteur).unwrap().as_ptr(),
|
||||||
|
CString::new(CodePorteurPS).unwrap().as_ptr(),
|
||||||
|
&mut ZDonneesSortie,
|
||||||
|
&mut TTailleDonneesSortie);
|
||||||
|
result
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,5 @@
|
|||||||
|
mod SV_DLL_Win;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
println!("Hello, world!");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user