Files
betterxen/crates/cli/tests/imports_sync.rs
T
zachdoxsee db40a1307d loader, cli: bound delay-load tables by their declared size (#244)
Address review on the delay-import probe change:

- Read only descriptors inside the delay import directory's declared
  size, and require that size to hold the terminating empty descriptor.
- Require each descriptor's DLL name, import address table and import
  name table to be present and to start in section data, with a
  diagnostic naming the missing field.
- Leave delayed rows out of the xenora imports sync backlog, so its
  totals stay ordinary-only.

Signed-off-by: zachdoxsee <zachdoxsee36@gmail.com>
2026-11-24 16:28:02 +01:00

36 lines
1.4 KiB
Rust

// SPDX-License-Identifier: GPL-3.0-or-later
//! `xenora imports sync` over a probe report that lists delay-loaded imports.
use std::process::Command;
#[test]
fn backlog_leaves_out_delay_loaded_imports() {
// `fixtures/pe/delay-imports.py` writes two ordinary imports from
// `fixture-ordinary.dll` and three delay-loaded ones from two other DLLs.
let fixture = concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../fixtures/pe/delay-imports.exe"
);
let report = std::env::temp_dir().join(format!("xenora-sync-delayed-{}", std::process::id()));
let xenora = |arguments: &[&str]| {
let status = Command::new(env!("CARGO_BIN_EXE_xenora"))
.args(arguments)
.arg("--report")
.arg(&report)
.status()
.unwrap();
assert!(status.success(), "{arguments:?}");
};
xenora(&["probe", "--pe", fixture]);
xenora(&["imports", "sync"]);
let listed = std::fs::read_to_string(report.join("imports.csv")).unwrap();
let backlog = std::fs::read_to_string(report.join("import_backlog.md")).unwrap();
std::fs::remove_dir_all(report).unwrap();
assert_eq!(listed.matches(",delayed,").count(), 3);
assert!(backlog.contains("| **Total** | 2 |"), "{backlog}");
assert!(backlog.contains("fixture-ordinary.dll"), "{backlog}");
assert!(!backlog.contains("fixture-delay"), "{backlog}");
}