corrected handling of FFI pointer to pointer to error struct for error output from leechcore

pull/10/head
ConnorBP 3 weeks ago
parent bf61f2b214
commit a29618e006

@ -124,13 +124,21 @@ 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() {
// 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