diff --git a/leechcore-sys/build.rs b/leechcore-sys/build.rs index 1e609f8..54a7e15 100644 --- a/leechcore-sys/build.rs +++ b/leechcore-sys/build.rs @@ -56,6 +56,7 @@ fn build_leechcore(target: &str) { .map(|o| "src/leechcore/leechcore/".to_string() + o) .collect::>(), ) + .include("src/leechcore/includes/") .flag(&format!("-D{}", os_define())) .flag("-D_GNU_SOURCE"); // EXPORTED_FUNCTION= to not export any symbols @@ -96,8 +97,8 @@ fn build_leechcore(target: &str) { } } else { // copy pre-compiled idl file into the leechcore folder - std::fs::copy("gen/leechrpc_c.c", "src/leechcore/leechcore/leechrpc_c.c").unwrap(); - std::fs::copy("gen/leechrpc_h.h", "src/leechcore/leechcore/leechrpc_h.h").unwrap(); + std::fs::copy("gen/leechrpc_c.c", "src/leechcore/leechcore/leechrpc_c.c").expect("Failed to copy leechrpc_c.c"); + std::fs::copy("gen/leechrpc_h.h", "src/leechcore/leechcore/leechrpc_h.h").expect("Failed to copy leechrpc_h.h"); // link against required libraries println!("cargo:rustc-link-lib=rpcrt4"); @@ -113,8 +114,8 @@ fn build_leechcore(target: &str) { if target.contains("windows") { // remove temporary generated files - std::fs::remove_file("src/leechcore/leechcore/leechrpc_c.c").unwrap(); - std::fs::remove_file("src/leechcore/leechcore/leechrpc_h.h").unwrap(); + std::fs::remove_file("src/leechcore/leechcore/leechrpc_c.c").expect("Failed to remove leechrpc_c.c"); + std::fs::remove_file("src/leechcore/leechcore/leechrpc_h.h").expect("Failed to remove leechrpc_h.h"); } println!("cargo:rustc-link-lib=static=leechcore"); diff --git a/leechcore-sys/src/leechcore b/leechcore-sys/src/leechcore index 258c958..0efa866 160000 --- a/leechcore-sys/src/leechcore +++ b/leechcore-sys/src/leechcore @@ -1 +1 @@ -Subproject commit 258c95894deb1a5d0cdeb0838152ac2312cb8bb8 +Subproject commit 0efa866043743ef010dc7f90f8ac95f83fe6dfd6 diff --git a/memflow-pcileech/src/lib.rs b/memflow-pcileech/src/lib.rs index 110e785..5306b8c 100644 --- a/memflow-pcileech/src/lib.rs +++ b/memflow-pcileech/src/lib.rs @@ -124,13 +124,22 @@ impl PciLeech { ) -> Result { // open device let mut conf = build_lc_config(device, remote, mem_map.is_some()); - let err = std::ptr::null_mut::(); - let handle = unsafe { LcCreateEx(&mut conf, err) }; + let p_lc_config_error_info = std::ptr::null_mut::(); + let pp_lc_config_error_info = &raw const p_lc_config_error_info as *mut PLC_CONFIG_ERRORINFO; + let handle = unsafe { LcCreateEx(&mut conf, pp_lc_config_error_info) }; if handle.is_null() { + error!("Unable to create leechcore context: {conf:?} ppErr: {pp_lc_config_error_info:?} pErr: {p_lc_config_error_info:?}"); // TODO: handle version error // TODO: handle special case of fUserInputRequest + let err = if p_lc_config_error_info.is_null() { + None + } else { + // read the data at the error + Some(unsafe { p_lc_config_error_info.read() }) + }; + return Err(Error(ErrorOrigin::Connector, ErrorKind::Configuration) - .log_error(format!("unable to create leechcore context: {err:?}"))); + .log_error(format!("unable to create leechcore context: {err:?}", ))); } // TODO: allow handling these errors properly