Merge pull request #10 from ConnorBP/fix-error-output

Updated pcileech dependency and improved error output
macos
ko1N 3 days ago committed by GitHub
commit 1984e9755c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -56,6 +56,7 @@ fn build_leechcore(target: &str) {
.map(|o| "src/leechcore/leechcore/".to_string() + o)
.collect::<Vec<_>>(),
)
.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");

@ -1 +1 @@
Subproject commit 258c95894deb1a5d0cdeb0838152ac2312cb8bb8
Subproject commit 0efa866043743ef010dc7f90f8ac95f83fe6dfd6

@ -124,13 +124,22 @@ impl PciLeech {
) -> Result<Self> {
// open device
let mut conf = build_lc_config(device, remote, mem_map.is_some());
let err = std::ptr::null_mut::<PLC_CONFIG_ERRORINFO>();
let handle = unsafe { LcCreateEx(&mut conf, err) };
let p_lc_config_error_info = std::ptr::null_mut::<LC_CONFIG_ERRORINFO>();
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

Loading…
Cancel
Save