ws: demonstrate thunk handling

ws: tests: assert missing function

ws: tests: assert more expected functions
This commit is contained in:
Willi Ballenthin 2025-02-18 21:06:43 +00:00
parent ce1087a5ba
commit 0932b328af
2 changed files with 213 additions and 3 deletions

View file

@ -51,10 +51,8 @@ impl Configuration for FileSystemConfiguration {
Ok(FlirtSignatureSet::with_signatures(sigs))
}
// not supported at this time
// its probably ok to make this return an empty list, as necessary
fn get_function_hints(&self) -> Result<Vec<VA>> {
unimplemented!("FileSystemConfiguration::get_function_hints()")
Ok(vec![])
}
fn clone(&self) -> Box<dyn Configuration> {

View file

@ -531,4 +531,216 @@ mod tests {
Ok(())
}
#[test]
fn ws_thunks() -> Result<()> {
//crate::test::init_logging();
let buf = get_buf(Rsrc::CPP1);
let config = get_config();
let ws = workspace_from_bytes(config, &buf)?;
let expected = [
0x140011005,
0x14001100a,
0x14001100f,
0x140011028,
0x14001102d,
0x140011046,
0x14001104b,
0x140011050,
0x140011055,
0x14001105a,
0x14001105f,
0x140011064,
0x140011069,
0x14001106e,
0x140011073,
0x140011078,
0x140011082,
0x140011087,
0x140011091,
0x140011096,
0x1400110a0,
0x1400110af,
0x1400110b4,
0x1400110be,
0x1400110c8,
0x1400110cd,
0x1400110d7,
0x1400110dc,
0x1400110e1,
0x1400110e6,
0x1400110fa,
0x140011104,
0x140011118,
0x140011122,
0x140011127,
0x14001112c,
0x140011136,
0x140011145,
0x14001114f,
0x140011154,
0x140011159,
0x14001115e,
0x140011168,
0x140011177,
0x14001117c,
0x140011181,
0x14001119a,
0x14001119f,
0x1400111a9,
0x1400111ae,
0x1400111b8,
0x1400111c2,
0x1400111c7,
0x1400111cc,
0x1400111d1,
0x1400111db,
0x1400111e5,
0x1400111ea,
0x1400111f4,
0x14001120d,
0x140011212,
0x140011217,
0x14001121c,
0x140011221,
0x14001122b,
0x140011230,
0x14001123a,
0x14001123f,
0x140011244,
0x140011249,
0x14001124e,
0x140011262,
0x14001126c,
0x140011271,
0x14001127b,
0x140011280,
0x140011294,
0x14001129e,
0x1400112a3,
0x1400112a8,
0x1400112ad,
0x1400112b7,
0x1400112bc,
0x1400112c6,
0x1400112cb,
0x1400112d5,
0x1400112da,
0x1400112e4,
0x1400112e9,
0x1400112f8,
0x14001130c,
0x140011307,
0x14001131b,
0x140011320,
0x140011325,
0x14001132a,
0x14001132f,
0x140011339,
0x140011343,
0x140011348,
0x14001134d,
0x140011352,
0x140011366,
0x140011370,
0x140011375,
0x14001137a,
0x140011389,
0x14001138e,
0x1400113ac,
0x1400113b1,
0x1400113b6,
0x1400113c0,
0x1400113c5,
0x1400113ca,
0x1400113cf,
0x1400113d9,
0x1400113de,
0x1400113e8,
0x1400113ed,
0x1400113f2,
0x1400113fc,
0x140011401,
0x140011406,
0x14001140b,
0x140011415,
0x14001141a,
0x14001141f,
0x140011424,
0x140011429,
0x14001143d,
0x14001144c,
0x140011460,
0x140011465,
0x14001146f,
0x140011474,
0x140011479,
0x14001147e,
0x140011483,
0x140011488,
0x140011492,
0x1400121f0,
0x140012f91,
0x1400157f0,
0x1400157f6,
0x1400157fc,
0x140015802,
0x140015808,
0x14001580e,
0x140015814,
0x14001581a,
0x140015820,
0x140015826,
0x14001582c,
0x140015832,
0x140015838,
0x14001583e,
0x140015844,
0x14001584a,
0x140015850,
0x140015856,
0x14001585c,
0x140015862,
0x140015868,
0x14001586e,
0x140015874,
0x14001587a,
0x140015880,
0x140015886,
0x14001588c,
0x140015892,
0x140015898,
0x14001589e,
0x1400158a4,
0x1400158aa,
0x1400158b0,
0x1400158fe,
];
for e in expected.iter() {
assert!(
ws.analysis().functions[e].flags.intersects(FunctionFlags::THUNK),
"expected thunk not present: 0x{e:x}"
);
}
for (function, analysis) in ws.analysis().functions.iter() {
if analysis.flags.intersects(FunctionFlags::THUNK) {
assert!(expected.contains(function), "extra thunk found: 0x{function:x}");
}
}
assert!(
ws.analysis().functions.contains_key(&0x140011CCC),
"missing function: sub_140011CCC"
);
assert!(
ws.analysis().functions.contains_key(&0x140014A30),
"missing function: __scrt_unhandled_exception_filter"
);
Ok(())
}
}